@skbkontur/side-menu 3.3.3 → 3.3.4
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/SideMenuDataTids.js +1 -4
- package/hooks/useAnimateOnMount.js +6 -9
- package/hooks/useMemoIcon.js +12 -18
- package/index.js +14 -17
- package/internal/themes/SideMenuTheme.js +10 -15
- package/lib/theming/ThemeHelpers.js +14 -20
- package/lib/theming/ThemeTypes.js +1 -2
- package/lib/utils/memo.js +1 -5
- package/lib/utils/scripts.js +5 -11
- package/package.json +3 -3
- package/src/Navigation.js +18 -21
- package/src/SideMenu/SideMenu.js +119 -120
- package/src/SideMenu/SideMenu.styles.js +28 -31
- package/src/SideMenuAvatar/SideMenuAvatar.d.ts +1 -1
- package/src/SideMenuAvatar/SideMenuAvatar.js +11 -14
- package/src/SideMenuBody/SideMenuBody.js +18 -21
- package/src/SideMenuBody/SideMenuBody.styles.js +6 -9
- package/src/SideMenuContext.d.ts +1 -1
- package/src/SideMenuContext.js +2 -5
- package/src/SideMenuDivider/SideMenuDivider.js +11 -14
- package/src/SideMenuDivider/SideMenuDivider.styles.js +5 -8
- package/src/SideMenuDropdown/SideMenuDropdown.d.ts +1 -1
- package/src/SideMenuDropdown/SideMenuDropdown.js +22 -24
- package/src/SideMenuDropdown/SideMenuDropdown.styles.js +9 -12
- package/src/SideMenuFooter/SideMenuFooter.js +21 -24
- package/src/SideMenuFooter/SideMenuFooter.styles.js +7 -10
- package/src/SideMenuHeader/SideMenuHeader.js +26 -29
- package/src/SideMenuHeader/SideMenuHeader.styles.js +9 -12
- package/src/SideMenuItem/SideMenuItem.js +7 -10
- package/src/SideMenuLink/SideMenuLink.js +9 -12
- package/src/SideMenuLink/SideMenuLink.styles.js +4 -7
- package/src/SideMenuNotifications/BellWidget.js +41 -45
- package/src/SideMenuNotifications/BellWidgetError.js +15 -20
- package/src/SideMenuNotifications/BellWidgetView.styles.js +11 -14
- package/src/SideMenuNotifications/SideMenuNotifications.js +23 -26
- package/src/SideMenuNotifications/utils/getMarker.js +1 -4
- package/src/SideMenuNotifications/utils/getNotificationsErrorMessages.js +1 -5
- package/src/SideMenuOrganisations/SideMenuOrganisations.js +7 -10
- package/src/SideMenuSubItem/SideMenuSubItem.js +8 -11
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.js +15 -18
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.js +6 -9
- package/src/SideMenuSubLink/SideMenuSubLink.js +7 -10
- package/src/Tree.js +9 -12
- package/src/internal/BackButton.js +10 -14
- package/src/internal/Backdrop.js +11 -15
- package/src/internal/Backdrop.styles.js +5 -8
- package/src/internal/Burger.js +12 -17
- package/src/internal/Burger.styles.js +6 -9
- package/src/internal/ClickableElement.js +44 -47
- package/src/internal/ClickableElement.styles.js +12 -15
- package/src/internal/InnerSubMenu.js +10 -14
- package/src/internal/ItemContent/Caption.js +31 -34
- package/src/internal/ItemContent/Caption.styles.js +20 -23
- package/src/internal/ItemContent/Icon.js +20 -25
- package/src/internal/ItemContent/Icon.styles.js +11 -14
- package/src/internal/ItemContent/ItemContent.js +33 -36
- package/src/internal/ItemContent/ItemContent.styles.js +15 -18
- package/src/internal/ItemContent/Marker.js +16 -21
- package/src/internal/ItemContent/Marker.styles.js +12 -15
- package/src/internal/NestedMenu.js +15 -19
- package/src/internal/NestedMenu.styles.js +5 -8
- package/src/internal/RightBorder.js +19 -22
- package/src/internal/RightBorder.styles.js +6 -9
- package/src/internal/SeparatedSubMenu.js +36 -40
- package/src/internal/SeparatedSubMenu.styles.js +13 -16
- package/src/internal/SideMenuLogotype.js +31 -34
- package/src/internal/SideMenuLogotype.styles.js +14 -17
- package/src/internal/SubMenu.js +11 -15
package/src/internal/Backdrop.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var Emotion_1 = require("@skbkontur/react-ui/lib/theming/Emotion");
|
|
9
|
-
var Backdrop_styles_1 = require("./Backdrop.styles");
|
|
10
|
-
var Backdrop = function (props) {
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { HideBodyVerticalScroll } from '@skbkontur/react-ui/internal/HideBodyVerticalScroll';
|
|
4
|
+
import { LIGHT_THEME } from '@skbkontur/react-ui/lib/theming/themes/LightTheme';
|
|
5
|
+
import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
6
|
+
import { jsStyles } from './Backdrop.styles';
|
|
7
|
+
export var Backdrop = function (props) {
|
|
11
8
|
var _a;
|
|
12
|
-
return (
|
|
13
|
-
_a[
|
|
14
|
-
_a)), style:
|
|
15
|
-
|
|
9
|
+
return (React.createElement("div", { className: cx((_a = {},
|
|
10
|
+
_a[jsStyles.rootForTabletsOrMobiles()] = true,
|
|
11
|
+
_a)), style: __assign({ background: LIGHT_THEME.sidePageBackingBg }, props.style) },
|
|
12
|
+
React.createElement(HideBodyVerticalScroll, null)));
|
|
16
13
|
};
|
|
17
|
-
exports.Backdrop = Backdrop;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var Emotion_1 = require("@skbkontur/react-ui/lib/theming/Emotion");
|
|
6
|
-
var SideMenu_1 = require("../SideMenu/SideMenu");
|
|
1
|
+
import { __makeTemplateObject } from "tslib";
|
|
2
|
+
import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
import { burgerTransitionDuration } from '../SideMenu/SideMenu';
|
|
7
4
|
var styles = {
|
|
8
5
|
rootForTabletsOrMobiles: function () {
|
|
9
|
-
return
|
|
6
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n transition: opacity ", "ms ease-out;\n "], ["\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n transition: opacity ", "ms ease-out;\n "])), burgerTransitionDuration);
|
|
10
7
|
},
|
|
11
8
|
};
|
|
12
|
-
|
|
9
|
+
export var jsStyles = memoizeStyle(styles);
|
|
13
10
|
var templateObject_1;
|
package/src/internal/Burger.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var context = (0, react_1.useContext)(SideMenuContext_1.SideMenuContext);
|
|
14
|
-
var theme = (0, ThemeHelpers_1.getSideMenuTheme)((0, react_1.useContext)(react_ui_1.ThemeContext));
|
|
15
|
-
return (react_1.default.createElement("button", { className: Burger_styles_1.jsStyles.rootForTabletsOrMobiles(theme), onClick: context.toggleIsOpened, "data-tid": SideMenuDataTids_1.SideMenuDataTids.burger },
|
|
16
|
-
react_1.default.createElement(UiMenuBars3HIcon24Regular_1.UiMenuBars3HIcon24Regular, null)));
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { UiMenuBars3HIcon24Regular } from '@skbkontur/icons/icons/UiMenuBars3HIcon/UiMenuBars3HIcon24Regular';
|
|
3
|
+
import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
|
|
4
|
+
import { SideMenuContext } from '../SideMenuContext';
|
|
5
|
+
import { SideMenuDataTids } from '../../SideMenuDataTids';
|
|
6
|
+
import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers';
|
|
7
|
+
import { jsStyles } from './Burger.styles';
|
|
8
|
+
export var Burger = function () {
|
|
9
|
+
var context = useContext(SideMenuContext);
|
|
10
|
+
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
11
|
+
return (React.createElement("button", { className: jsStyles.rootForTabletsOrMobiles(theme), onClick: context.toggleIsOpened, "data-tid": SideMenuDataTids.burger },
|
|
12
|
+
React.createElement(UiMenuBars3HIcon24Regular, null)));
|
|
17
13
|
};
|
|
18
|
-
exports.Burger = Burger;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var Emotion_1 = require("@skbkontur/react-ui/lib/theming/Emotion");
|
|
6
|
-
var Mixins_1 = require("@skbkontur/react-ui/lib/styles/Mixins");
|
|
7
|
-
var ThemeHelpers_1 = require("../../lib/theming/ThemeHelpers");
|
|
1
|
+
import { __makeTemplateObject } from "tslib";
|
|
2
|
+
import { css } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
import { resetButton } from '@skbkontur/react-ui/lib/styles/Mixins';
|
|
4
|
+
import { memoizeStyle } from '../../lib/theming/ThemeHelpers';
|
|
8
5
|
var styles = {
|
|
9
6
|
rootForTabletsOrMobiles: function (t) {
|
|
10
|
-
return
|
|
7
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n margin-right: ", ";\n cursor: pointer;\n "], ["\n ", ";\n margin-right: ", ";\n cursor: pointer;\n "])), resetButton(), t.sideMenuBurgerMarginRight);
|
|
11
8
|
},
|
|
12
9
|
};
|
|
13
|
-
|
|
10
|
+
export var jsStyles = memoizeStyle(styles);
|
|
14
11
|
var templateObject_1;
|
|
@@ -1,41 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var ClickableElement_styles_1 = require("./ClickableElement.styles");
|
|
16
|
-
var SubMenu_1 = require("./SubMenu");
|
|
17
|
-
var ItemContent_1 = require("./ItemContent/ItemContent");
|
|
1
|
+
import { __assign, __read, __rest } from "tslib";
|
|
2
|
+
import React, { forwardRef, useContext, useEffect, useState } from 'react';
|
|
3
|
+
import { keyListener } from '@skbkontur/react-ui/lib/events/keyListener';
|
|
4
|
+
import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
5
|
+
import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
|
|
6
|
+
import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers';
|
|
7
|
+
import { SideMenuContext } from '../SideMenuContext';
|
|
8
|
+
import { useMemoIcon } from '../../hooks/useMemoIcon';
|
|
9
|
+
import { SideMenuDataTids } from '../../SideMenuDataTids';
|
|
10
|
+
import { navigationAttribute } from '../Navigation';
|
|
11
|
+
import { generateId } from '../../lib/utils/scripts';
|
|
12
|
+
import { jsStyles } from './ClickableElement.styles';
|
|
13
|
+
import { SubMenu } from './SubMenu';
|
|
14
|
+
import { ItemContent } from './ItemContent/ItemContent';
|
|
18
15
|
/**
|
|
19
16
|
* Элемент списка (пункт меню либо ссылка)
|
|
20
17
|
*
|
|
21
18
|
* @visibleName ClickableElement
|
|
22
19
|
*/
|
|
23
|
-
var ClickableElement =
|
|
20
|
+
var ClickableElement = forwardRef(function (_a, ref) {
|
|
24
21
|
var _b, _c;
|
|
25
|
-
var onClick = _a.onClick, icon = _a.icon, marker = _a.marker, caption = _a.caption, subCaption = _a.subCaption, id = _a.id, _isSubMenu = _a._isSubMenu, children = _a.children, Tag = _a.element, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onBlur = _a.onBlur, className = _a.className, _isDropdown = _a._isDropdown, _isBackButton = _a._isBackButton, _isAvatar = _a._isAvatar, isButton = _a.isButton, href = _a.href, disabled = _a.disabled, rest =
|
|
26
|
-
var context =
|
|
27
|
-
var theme =
|
|
28
|
-
var _d =
|
|
29
|
-
var _e =
|
|
30
|
-
var _f =
|
|
31
|
-
var _g =
|
|
32
|
-
var _h =
|
|
33
|
-
var _j =
|
|
34
|
-
var _k =
|
|
35
|
-
|
|
22
|
+
var onClick = _a.onClick, icon = _a.icon, marker = _a.marker, caption = _a.caption, subCaption = _a.subCaption, id = _a.id, _isSubMenu = _a._isSubMenu, children = _a.children, Tag = _a.element, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onBlur = _a.onBlur, className = _a.className, _isDropdown = _a._isDropdown, _isBackButton = _a._isBackButton, _isAvatar = _a._isAvatar, isButton = _a.isButton, href = _a.href, disabled = _a.disabled, rest = __rest(_a, ["onClick", "icon", "marker", "caption", "subCaption", "id", "_isSubMenu", "children", "element", "onKeyDown", "onFocus", "onBlur", "className", "_isDropdown", "_isBackButton", "_isAvatar", "isButton", "href", "disabled"]);
|
|
23
|
+
var context = useContext(SideMenuContext);
|
|
24
|
+
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
25
|
+
var _d = __read(useState(false), 2), isActive = _d[0], setIsActive = _d[1];
|
|
26
|
+
var _e = __read(useState(false), 2), isFirstLevelParentOfActiveMenuItem = _e[0], setIsFirstLevelParentOfActiveMenuItem = _e[1];
|
|
27
|
+
var _f = __read(useState(false), 2), isOpened = _f[0], setIsOpened = _f[1];
|
|
28
|
+
var _g = __read(useState(false), 2), isNestedSubMenu = _g[0], setIsNestedSubMenu = _g[1];
|
|
29
|
+
var _h = __read(useState(false), 2), hasSubIcons = _h[0], setHasSubIcons = _h[1];
|
|
30
|
+
var _j = __read(useState(false), 2), isFocusedByTab = _j[0], setIsFocusedByTab = _j[1];
|
|
31
|
+
var _k = __read(useState(id || href || ''), 2), currentId = _k[0], setCurrentId = _k[1];
|
|
32
|
+
useEffect(function () {
|
|
36
33
|
var _a;
|
|
37
34
|
if (!currentId) {
|
|
38
|
-
var generatedId =
|
|
35
|
+
var generatedId = generateId();
|
|
39
36
|
setCurrentId(generatedId);
|
|
40
37
|
}
|
|
41
38
|
(_a = context.navigation) === null || _a === void 0 ? void 0 : _a.addValue(currentId, {
|
|
@@ -103,7 +100,7 @@ var ClickableElement = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
103
100
|
var handleFocus = function (e) {
|
|
104
101
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
105
102
|
requestAnimationFrame(function () {
|
|
106
|
-
if (
|
|
103
|
+
if (keyListener.isTabPressed) {
|
|
107
104
|
setIsFocusedByTab(true);
|
|
108
105
|
}
|
|
109
106
|
});
|
|
@@ -124,25 +121,25 @@ var ClickableElement = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
124
121
|
e.stopPropagation();
|
|
125
122
|
(_d = (_c = (_b = (_a = context.navigation) === null || _a === void 0 ? void 0 : _a.navigationTree) === null || _b === void 0 ? void 0 : _b.find(currentId)) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.setIsOpened(false);
|
|
126
123
|
};
|
|
127
|
-
var newProps =
|
|
128
|
-
_b[
|
|
129
|
-
_b[
|
|
130
|
-
_b[
|
|
131
|
-
_b[
|
|
132
|
-
_b[
|
|
133
|
-
_b[
|
|
134
|
-
_b[
|
|
135
|
-
_b), className), onClick: handleClick, onFocus: handleFocus, onBlur: handleBlur, children: (
|
|
124
|
+
var newProps = __assign({ className: cx((_b = {},
|
|
125
|
+
_b[jsStyles.root(theme)] = true,
|
|
126
|
+
_b[jsStyles.rootButton(theme)] = isButton,
|
|
127
|
+
_b[jsStyles.rootSubItemInSeparatedSubMenu(theme)] = context.isSeparatedMenu && _isSubMenu,
|
|
128
|
+
_b[jsStyles.focusedRoot(theme)] = isFocusedByTab,
|
|
129
|
+
_b[jsStyles.disabledRoot(theme)] = disabled,
|
|
130
|
+
_b[jsStyles.activeRoot(theme)] = isHighlighted,
|
|
131
|
+
_b[jsStyles.activeRootSubItemInSeparatedSubMenu(theme)] = isActive && context.isSeparatedMenu && _isSubMenu,
|
|
132
|
+
_b), className), onClick: handleClick, onFocus: handleFocus, onBlur: handleBlur, children: (React.createElement(ItemContent, { _isSubMenu: _isSubMenu,
|
|
136
133
|
// @ts-expect-error: SideMenuItem should have icon
|
|
137
|
-
icon: _isSubMenu && !_isBackButton ?
|
|
138
|
-
return (
|
|
139
|
-
|
|
140
|
-
?
|
|
141
|
-
|
|
142
|
-
|
|
134
|
+
icon: _isSubMenu && !_isBackButton ? useMemoIcon(children, { isOpened: isOpened, onClick: handleCollapse }) : icon, isNestedSubMenu: isNestedSubMenu, caption: caption, subCaption: subCaption, marker: marker, _isBackButton: _isBackButton, _isDropdown: _isDropdown, _isAvatar: _isAvatar, disabled: disabled })), ref: ref, href: href }, rest);
|
|
135
|
+
return (React.createElement(Component, (_c = { "data-tid": SideMenuDataTids.clickableElement }, _c[navigationAttribute] = currentId, _c),
|
|
136
|
+
React.cloneElement(React.createElement(Tag, { state: isActive ? 'active' : undefined }), children
|
|
137
|
+
? __assign(__assign({}, newProps), { 'aria-expanded': children ? isOpened : undefined, 'aria-controls': children ? currentId : undefined }) : __assign({}, newProps)),
|
|
138
|
+
React.createElement(SubMenu, { caption: caption, isSubMenu: _isSubMenu, isSeparatedMenu: context.isSeparatedMenu, htmlId: currentId, isOpened: isOpened },
|
|
139
|
+
React.createElement(SideMenuContext.Provider, { value: __assign({ hasSubIcons: hasSubIcons }, context) }, children))));
|
|
143
140
|
});
|
|
144
141
|
ClickableElement.displayName = 'ClickableElement';
|
|
145
142
|
var ClickableElementWithStaticFields = Object.assign(ClickableElement, {
|
|
146
143
|
__KONTUR_REACT_UI__: 'ClickableElement',
|
|
147
144
|
});
|
|
148
|
-
|
|
145
|
+
export { ClickableElementWithStaticFields as ClickableElement };
|
|
@@ -1,32 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var Emotion_1 = require("@skbkontur/react-ui/lib/theming/Emotion");
|
|
6
|
-
var Mixins_1 = require("@skbkontur/react-ui/lib/styles/Mixins");
|
|
7
|
-
var ThemeHelpers_1 = require("../../lib/theming/ThemeHelpers");
|
|
1
|
+
import { __makeTemplateObject } from "tslib";
|
|
2
|
+
import { css } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
import { resetButton } from '@skbkontur/react-ui/lib/styles/Mixins';
|
|
4
|
+
import { memoizeStyle } from '../../lib/theming/ThemeHelpers';
|
|
8
5
|
var styles = {
|
|
9
6
|
root: function (t) {
|
|
10
|
-
return
|
|
7
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n user-select: text;\n ", ";\n width: 100%;\n border-radius: ", ";\n cursor: pointer;\n &:hover {\n background: ", ";\n }\n "], ["\n user-select: text;\n ", ";\n width: 100%;\n border-radius: ", ";\n cursor: pointer;\n &:hover {\n background: ", ";\n }\n "])), resetButton(), t.sideMenuItemBorderRadius, t.sideMenuItemHoverBg);
|
|
11
8
|
},
|
|
12
9
|
rootButton: function (t) {
|
|
13
|
-
return
|
|
10
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n &:active {\n background: ", ";\n }\n "], ["\n &:active {\n background: ", ";\n }\n "])), t.sideMenuItemActiveBg);
|
|
14
11
|
},
|
|
15
12
|
rootSubItemInSeparatedSubMenu: function (t) {
|
|
16
|
-
return
|
|
13
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n &:hover {\n background: ", ";\n }\n "], ["\n &:hover {\n background: ", ";\n }\n "])), t.sideMenuSubItemWithSeparatedSubMenuHoverBg);
|
|
17
14
|
},
|
|
18
15
|
focusedRoot: function (t) {
|
|
19
|
-
return
|
|
16
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n box-shadow: ", ";\n "], ["\n box-shadow: ", ";\n "])), t.sideMenuFocusedItemBoxShadow);
|
|
20
17
|
},
|
|
21
18
|
disabledRoot: function (t) {
|
|
22
|
-
return
|
|
19
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n color: ", ";\n pointer-events: none;\n "], ["\n color: ", ";\n pointer-events: none;\n "])), t.sideMenuItemDisabledColor);
|
|
23
20
|
},
|
|
24
21
|
activeRoot: function (t) {
|
|
25
|
-
return
|
|
22
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n background: ", " !important;\n "], ["\n background: ", " !important;\n "])), t.sideMenuItemActiveBg);
|
|
26
23
|
},
|
|
27
24
|
activeRootSubItemInSeparatedSubMenu: function (t) {
|
|
28
|
-
return
|
|
25
|
+
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n background: ", " !important;\n "], ["\n background: ", " !important;\n "])), t.sideMenuSubItemWithSeparatedSubMenuActiveBg);
|
|
29
26
|
},
|
|
30
27
|
};
|
|
31
|
-
|
|
28
|
+
export var jsStyles = memoizeStyle(styles);
|
|
32
29
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
-
var Emotion_1 = require("@skbkontur/react-ui/lib/theming/Emotion");
|
|
7
|
-
var SideMenu_styles_1 = require("../SideMenu/SideMenu.styles");
|
|
8
|
-
var SideMenuContext_1 = require("../SideMenuContext");
|
|
1
|
+
import React, { forwardRef, useContext } from 'react';
|
|
2
|
+
import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
import { jsStylesForSideMenu } from '../SideMenu/SideMenu.styles';
|
|
4
|
+
import { SideMenuContext } from '../SideMenuContext';
|
|
9
5
|
/**
|
|
10
6
|
* Подменю, раскрывающееся внутри основного меню
|
|
11
7
|
*
|
|
12
8
|
* @visibleName InnerSubMenu
|
|
13
9
|
*/
|
|
14
|
-
var InnerSubMenu =
|
|
10
|
+
var InnerSubMenu = forwardRef(function (_a, ref) {
|
|
15
11
|
var _b;
|
|
16
12
|
var children = _a.children, htmlId = _a.htmlId, isOpened = _a.isOpened;
|
|
17
|
-
var context =
|
|
18
|
-
return (
|
|
19
|
-
_b[
|
|
20
|
-
_b[
|
|
13
|
+
var context = useContext(SideMenuContext);
|
|
14
|
+
return (React.createElement("ul", { ref: ref, id: htmlId, className: cx((_b = {},
|
|
15
|
+
_b[jsStylesForSideMenu.list()] = true,
|
|
16
|
+
_b[jsStylesForSideMenu.hidden()] = !isOpened || !context.isOpened,
|
|
21
17
|
_b)) }, children));
|
|
22
18
|
});
|
|
23
19
|
InnerSubMenu.displayName = 'InnerSubMenu';
|
|
24
20
|
var InnerSubMenuWithStaticFields = Object.assign(InnerSubMenu, { __KONTUR_REACT_UI__: 'InnerSubMenu' });
|
|
25
|
-
|
|
21
|
+
export { InnerSubMenuWithStaticFields as InnerSubMenu };
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var SideMenuContext_1 = require("../../SideMenuContext");
|
|
9
|
-
var ThemeHelpers_1 = require("../../../lib/theming/ThemeHelpers");
|
|
10
|
-
var Caption_styles_1 = require("./Caption.styles");
|
|
1
|
+
import { __read } from "tslib";
|
|
2
|
+
import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
|
|
4
|
+
import React, { forwardRef, useContext, useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { SideMenuContext } from '../../SideMenuContext';
|
|
6
|
+
import { getSideMenuTheme } from '../../../lib/theming/ThemeHelpers';
|
|
7
|
+
import { jsStyles } from './Caption.styles';
|
|
11
8
|
var getTruncatedUserName = function (caption, visibleWidth, fullWidth) {
|
|
12
|
-
var _a =
|
|
9
|
+
var _a = __read(caption.split(' '), 2), firstName = _a[0], lastName = _a[1];
|
|
13
10
|
if (visibleWidth < fullWidth && lastName) {
|
|
14
11
|
return "".concat(firstName, " ").concat(lastName[0], ".");
|
|
15
12
|
}
|
|
@@ -24,15 +21,15 @@ var getCaptionTail = function (caption, visibleWidth, fullWidth) {
|
|
|
24
21
|
}
|
|
25
22
|
return '';
|
|
26
23
|
};
|
|
27
|
-
|
|
24
|
+
export var Caption = forwardRef(function (_a, ref) {
|
|
28
25
|
var _b, _c;
|
|
29
26
|
var _isSubMenu = _a._isSubMenu, isNestedSubMenu = _a.isNestedSubMenu, hasIcon = _a.hasIcon, caption = _a.caption, subCaption = _a.subCaption, isMultiline = _a.isMultiline, _isBackButton = _a._isBackButton, _isDropdown = _a._isDropdown, _isAvatar = _a._isAvatar;
|
|
30
|
-
var theme =
|
|
31
|
-
var _d =
|
|
32
|
-
var captionRef =
|
|
33
|
-
var _e =
|
|
27
|
+
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
28
|
+
var _d = useContext(SideMenuContext), isBeingTransitioned = _d.isBeingTransitioned, isSeparatedMenu = _d.isSeparatedMenu, size = _d.size, isTouchScreen = _d.isTouchScreen, hasSubIcons = _d.hasSubIcons;
|
|
29
|
+
var captionRef = useRef(null);
|
|
30
|
+
var _e = __read(useState(''), 2), tail = _e[0], setTail = _e[1];
|
|
34
31
|
var isCaptionPlainText = typeof caption === 'string';
|
|
35
|
-
|
|
32
|
+
useEffect(function () {
|
|
36
33
|
if (!_isDropdown || !captionRef.current || !caption || !isCaptionPlainText) {
|
|
37
34
|
return;
|
|
38
35
|
}
|
|
@@ -52,26 +49,26 @@ exports.Caption = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
52
49
|
return _isAvatar && userName.split(' ').length === 1;
|
|
53
50
|
};
|
|
54
51
|
var Component = isCaptionPlainText ? 'p' : 'div';
|
|
55
|
-
return (
|
|
56
|
-
_b[
|
|
57
|
-
_b[
|
|
52
|
+
return (React.createElement("div", { className: cx((_b = {},
|
|
53
|
+
_b[jsStyles.root()] = true,
|
|
54
|
+
_b[jsStyles.rootMultiline()] = isMultiline && !_isSubMenu,
|
|
58
55
|
_b)), ref: ref },
|
|
59
|
-
|
|
60
|
-
_c[
|
|
61
|
-
_c[
|
|
62
|
-
_c[
|
|
56
|
+
React.createElement(Component, { className: cx((_c = {},
|
|
57
|
+
_c[jsStyles.caption(theme)] = true,
|
|
58
|
+
_c[jsStyles.captionDropdown()] = _isDropdown,
|
|
59
|
+
_c[jsStyles.captionTruncated()] = isCaptionPlainText &&
|
|
63
60
|
_isDropdown &&
|
|
64
61
|
(!_isAvatar || isAvatarCaptionSingleWord(caption, _isAvatar)),
|
|
65
|
-
_c[
|
|
66
|
-
_c[
|
|
67
|
-
_c[
|
|
68
|
-
_c[
|
|
69
|
-
_c[
|
|
70
|
-
_c[
|
|
71
|
-
_c[
|
|
72
|
-
_c[
|
|
73
|
-
_c[
|
|
62
|
+
_c[jsStyles.captionSubItem(theme)] = _isSubMenu,
|
|
63
|
+
_c[jsStyles.captionSubItemSeparatedMenuTopLevel()] = isSeparatedMenu && !isNestedSubMenu && _isSubMenu && !hasIcon,
|
|
64
|
+
_c[jsStyles.captionNestedItemSeparatedMenu()] = isSeparatedMenu && isNestedSubMenu && !hasIcon,
|
|
65
|
+
_c[jsStyles.captionWithoutItemIcon()] = !hasIcon && !isSeparatedMenu,
|
|
66
|
+
_c[jsStyles.captionSubItemWithoutColumnIcons()] = _isSubMenu && isSeparatedMenu && !hasSubIcons,
|
|
67
|
+
_c[jsStyles.captionLarge(theme)] = size === 'large',
|
|
68
|
+
_c[jsStyles.captionForTouchScreens(theme)] = isTouchScreen,
|
|
69
|
+
_c[jsStyles.captionSubItemForTouchScreens(theme)] = isTouchScreen && _isSubMenu,
|
|
70
|
+
_c[jsStyles.captionInBackButton(theme)] = _isBackButton,
|
|
74
71
|
_c)), ref: captionRef, "data-tail": tail }, caption),
|
|
75
72
|
subCaption));
|
|
76
73
|
});
|
|
77
|
-
|
|
74
|
+
Caption.displayName = 'Caption';
|
|
@@ -1,54 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var ThemeHelpers_1 = require("../../../lib/theming/ThemeHelpers");
|
|
7
|
-
exports.sideMenuMultilineCaptionPaddingTop = '4px';
|
|
8
|
-
exports.sideMenuCaptionMarginRight = '8px';
|
|
1
|
+
import { __makeTemplateObject } from "tslib";
|
|
2
|
+
import { css } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
import { memoizeStyle } from '../../../lib/theming/ThemeHelpers';
|
|
4
|
+
export var sideMenuMultilineCaptionPaddingTop = '4px';
|
|
5
|
+
export var sideMenuCaptionMarginRight = '8px';
|
|
9
6
|
var styles = {
|
|
10
7
|
root: function () {
|
|
11
|
-
return
|
|
8
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n flex: 1;\n overflow: hidden;\n "], ["\n display: flex;\n flex-direction: column;\n flex: 1;\n overflow: hidden;\n "])));
|
|
12
9
|
},
|
|
13
10
|
rootMultiline: function () {
|
|
14
|
-
return
|
|
11
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding-top: ", ";\n align-self: flex-start;\n "], ["\n padding-top: ", ";\n align-self: flex-start;\n "])), sideMenuMultilineCaptionPaddingTop);
|
|
15
12
|
},
|
|
16
13
|
caption: function (t) {
|
|
17
|
-
return
|
|
14
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n margin: 0 ", " 0 0;\n overflow-wrap: anywhere;\n "], ["\n font-size: ", ";\n line-height: ", ";\n margin: 0 ", " 0 0;\n overflow-wrap: anywhere;\n "])), t.sideMenuCaptionFontSize, t.sideMenuCaptionLineHeight, sideMenuCaptionMarginRight);
|
|
18
15
|
},
|
|
19
16
|
captionForTouchScreens: function (t) {
|
|
20
|
-
return
|
|
17
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-size: ", ";\n line-height: ", ";\n "])), t.sideMenuCaptionFontSizeForTouchScreens, t.sideMenuCaptionLineHeightForTouchScreens);
|
|
21
18
|
},
|
|
22
19
|
captionSubItem: function (t) {
|
|
23
|
-
return
|
|
20
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n margin-left: ", ";\n "], ["\n margin-left: ", ";\n "])), t.sideMenuCaptionSubItemMarginLeft);
|
|
24
21
|
},
|
|
25
22
|
captionSubItemForTouchScreens: function (t) {
|
|
26
|
-
return
|
|
23
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-size: ", ";\n line-height: ", ";\n "])), t.sideMenuCaptionSubItemFontSizeForTouchScreens, t.sideMenuCaptionSubItemLineHeightForTouchScreens);
|
|
27
24
|
},
|
|
28
25
|
captionSubItemSeparatedMenuTopLevel: function () {
|
|
29
|
-
return
|
|
26
|
+
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n margin: 0 8px;\n "], ["\n margin: 0 8px;\n "])));
|
|
30
27
|
},
|
|
31
28
|
captionNestedItemSeparatedMenu: function () {
|
|
32
|
-
return
|
|
29
|
+
return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n margin-left: 25px;\n "], ["\n margin-left: 25px;\n "])));
|
|
33
30
|
},
|
|
34
31
|
captionWithoutItemIcon: function () {
|
|
35
|
-
return
|
|
32
|
+
return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n margin-left: 40px;\n "], ["\n margin-left: 40px;\n "])));
|
|
36
33
|
},
|
|
37
34
|
captionSubItemWithoutColumnIcons: function () {
|
|
38
|
-
return
|
|
35
|
+
return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n margin-left: 8px;\n "], ["\n margin-left: 8px;\n "])));
|
|
39
36
|
},
|
|
40
37
|
captionLarge: function (t) {
|
|
41
|
-
return
|
|
38
|
+
return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n font-size: ", " !important;\n line-height: ", " !important;\n "], ["\n font-size: ", " !important;\n line-height: ", " !important;\n "])), t.sideMenuCaptionLargeFontSize, t.sideMenuCaptionLargeLineHeight);
|
|
42
39
|
},
|
|
43
40
|
captionInBackButton: function (t) {
|
|
44
|
-
return
|
|
41
|
+
return css(templateObject_12 || (templateObject_12 = __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
42
|
},
|
|
46
43
|
captionDropdown: function () {
|
|
47
|
-
return
|
|
44
|
+
return css(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n white-space: nowrap;\n overflow: hidden;\n "], ["\n white-space: nowrap;\n overflow: hidden;\n "])));
|
|
48
45
|
},
|
|
49
46
|
captionTruncated: function () {
|
|
50
|
-
return
|
|
47
|
+
return css(templateObject_14 || (templateObject_14 = __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
48
|
},
|
|
52
49
|
};
|
|
53
|
-
|
|
50
|
+
export var jsStyles = memoizeStyle(styles);
|
|
54
51
|
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;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var SideMenuContext_1 = require("../../SideMenuContext");
|
|
9
|
-
var ThemeHelpers_1 = require("../../../lib/theming/ThemeHelpers");
|
|
10
|
-
var scripts_1 = require("../../../lib/utils/scripts");
|
|
11
|
-
var Icon_styles_1 = require("./Icon.styles");
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
|
|
4
|
+
import { SideMenuContext } from '../../SideMenuContext';
|
|
5
|
+
import { getSideMenuTheme } from '../../../lib/theming/ThemeHelpers';
|
|
6
|
+
import { isKonturIcon } from '../../../lib/utils/scripts';
|
|
7
|
+
import { jsStyles } from './Icon.styles';
|
|
12
8
|
var getIconSize = function (theme, _isSubMenu, _isBackButton) {
|
|
13
9
|
if (!_isSubMenu) {
|
|
14
10
|
return parseInt(theme.sideMenuIconSize);
|
|
@@ -17,16 +13,16 @@ var getIconSize = function (theme, _isSubMenu, _isBackButton) {
|
|
|
17
13
|
return parseInt(theme.sideMenuIconSubItemSize);
|
|
18
14
|
}
|
|
19
15
|
};
|
|
20
|
-
var Icon = function (_a) {
|
|
16
|
+
export var Icon = function (_a) {
|
|
21
17
|
var _b;
|
|
22
18
|
var icon = _a.icon, _isSubMenu = _a._isSubMenu, isMultiline = _a.isMultiline, _c = _a._isBackButton, _isBackButton = _c === void 0 ? false : _c, disabled = _a.disabled;
|
|
23
|
-
var context =
|
|
19
|
+
var context = useContext(SideMenuContext);
|
|
24
20
|
var isSeparatedMenu = context.isSeparatedMenu, size = context.size;
|
|
25
|
-
var theme =
|
|
21
|
+
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
26
22
|
var renderIcon = function () {
|
|
27
23
|
var iconColor = _isSubMenu && !disabled ? theme.sideMenuIconSubItemColor : undefined;
|
|
28
|
-
if (
|
|
29
|
-
return
|
|
24
|
+
if (isKonturIcon(icon)) {
|
|
25
|
+
return React.cloneElement(icon, {
|
|
30
26
|
size: getIconSize(theme, _isSubMenu, _isBackButton),
|
|
31
27
|
color: iconColor,
|
|
32
28
|
align: _isBackButton ? 'baseline' : 'none',
|
|
@@ -34,14 +30,13 @@ var Icon = function (_a) {
|
|
|
34
30
|
}
|
|
35
31
|
return icon;
|
|
36
32
|
};
|
|
37
|
-
return (
|
|
38
|
-
_b[
|
|
39
|
-
_b[
|
|
40
|
-
_b[
|
|
41
|
-
_b[
|
|
42
|
-
_b[
|
|
43
|
-
_b[
|
|
44
|
-
_b[
|
|
33
|
+
return (React.createElement("span", { className: cx((_b = {},
|
|
34
|
+
_b[jsStyles.root(theme)] = true,
|
|
35
|
+
_b[jsStyles.rootMultiline()] = isMultiline && (context.isOpened || _isSubMenu),
|
|
36
|
+
_b[jsStyles.rootLarge(theme)] = size === 'large',
|
|
37
|
+
_b[jsStyles.rootSubItem(theme)] = _isSubMenu,
|
|
38
|
+
_b[jsStyles.rootSubItemSeparatedMenu(theme)] = isSeparatedMenu && _isSubMenu,
|
|
39
|
+
_b[jsStyles.rootSubItemLarge(theme)] = _isSubMenu && size === 'large',
|
|
40
|
+
_b[jsStyles.rootBackButton(theme)] = _isBackButton,
|
|
45
41
|
_b)) }, renderIcon()));
|
|
46
42
|
};
|
|
47
|
-
exports.Icon = Icon;
|