@skbkontur/side-menu 4.0.10 → 5.0.0-alpha.1
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 +4 -0
- package/internal/themes/SideMenuTheme.d.ts +7 -7
- package/internal/themes/SideMenuTheme.js +9 -23
- 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 +1 -1
- package/src/SideMenu/SideMenu.d.ts +7 -4
- package/src/SideMenu/SideMenu.js +165 -179
- package/src/SideMenu/SideMenu.styles.d.ts +1 -0
- package/src/SideMenu/SideMenu.styles.js +12 -6
- package/src/SideMenuAvatar/SideMenuAvatar.js +7 -2
- package/src/SideMenuContext.d.ts +21 -9
- package/src/SideMenuContext.js +6 -1
- package/src/SideMenuDropdown/SideMenuDropdown.js +19 -19
- package/src/SideMenuDropdown/SideMenuDropdown.styles.js +9 -8
- package/src/SideMenuFooter/SideMenuFooter.js +21 -3
- package/src/SideMenuFooter/SideMenuFooter.styles.d.ts +4 -0
- package/src/SideMenuFooter/SideMenuFooter.styles.js +16 -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 +1 -0
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.d.ts +1 -0
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.js +5 -2
- package/src/SideMenuSubLink/SideMenuSubLink.d.ts +1 -1
- package/src/internal/BackButton.d.ts +1 -3
- package/src/internal/BackButton.js +4 -3
- package/src/internal/ClickableElement.d.ts +18 -2
- package/src/internal/ClickableElement.js +190 -69
- package/src/internal/ClickableElement.styles.d.ts +4 -0
- package/src/internal/ClickableElement.styles.js +19 -7
- package/src/internal/CollapseToggle.d.ts +2 -0
- package/src/internal/CollapseToggle.js +40 -0
- package/src/internal/{RightBorder.styles.d.ts → CollapseToggle.styles.d.ts} +0 -1
- package/src/internal/CollapseToggle.styles.js +13 -0
- package/src/internal/ItemContent/Caption.d.ts +1 -1
- package/src/internal/ItemContent/Caption.js +9 -26
- package/src/internal/ItemContent/Icon.js +3 -2
- package/src/internal/ItemContent/Icon.styles.d.ts +1 -0
- package/src/internal/ItemContent/Icon.styles.js +6 -3
- package/src/internal/ItemContent/ItemContent.js +17 -5
- package/src/internal/ItemContent/ItemContent.styles.d.ts +1 -0
- package/src/internal/ItemContent/ItemContent.styles.js +7 -4
- package/src/internal/NarrowAccordionDropdown.d.ts +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
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { __assign, __rest } from "tslib";
|
|
1
|
+
import { __assign, __read, __rest } from "tslib";
|
|
2
2
|
import { DropdownMenu } from '@skbkontur/react-ui/components/DropdownMenu';
|
|
3
3
|
import { useStyles, useEmotion } from '@skbkontur/react-ui/lib/renderEnvironment';
|
|
4
4
|
import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
|
|
5
|
-
import React, { forwardRef, useContext } from 'react';
|
|
5
|
+
import React, { forwardRef, useContext, useMemo, useState } from 'react';
|
|
6
6
|
import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers.js';
|
|
7
7
|
import { SideMenuContext } from '../SideMenuContext.js';
|
|
8
8
|
import { SideMenuItem } from '../SideMenuItem/SideMenuItem.js';
|
|
@@ -12,24 +12,11 @@ var SideMenuDropdownInner = forwardRef(function (_a, ref) {
|
|
|
12
12
|
var icon = _a.icon, id = _a.id, children = _a.children, caption = _a.caption, marker = _a.marker, subCaption = _a.subCaption, className = _a.className, menuWidth = _a.menuWidth, _isAvatar = _a._isAvatar, onClose = _a.onClose, onOpen = _a.onOpen, ariaLabel = _a["aria-label"], rest = __rest(_a, ["icon", "id", "children", "caption", "marker", "subCaption", "className", "menuWidth", "_isAvatar", "onClose", "onOpen", 'aria-label']);
|
|
13
13
|
var context = useContext(SideMenuContext);
|
|
14
14
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
15
|
+
var _c = __read(useState(false), 2), isMenuOpen = _c[0], setIsMenuOpen = _c[1];
|
|
15
16
|
var cx = useEmotion().cx;
|
|
16
17
|
var styles = useStyles(getStyles);
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
(_a = context.handleDropdownOpen) === null || _a === void 0 ? void 0 : _a.call(context);
|
|
20
|
-
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
21
|
-
};
|
|
22
|
-
var handleClose = function () {
|
|
23
|
-
var _a;
|
|
24
|
-
(_a = context.handleDropdownClose) === null || _a === void 0 ? void 0 : _a.call(context);
|
|
25
|
-
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
26
|
-
};
|
|
27
|
-
return (React.createElement("li", { className: cx(styles.wrapper(), className) },
|
|
28
|
-
React.createElement(DropdownMenu, __assign({ ref: ref, caption: React.createElement("div", { className: cx(styles.label(theme), (_b = {},
|
|
29
|
-
_b[styles.labelTouchScreen(theme)] = context.isTouchScreen,
|
|
30
|
-
_b[styles.labelCollapsed()] = !context.isOpened,
|
|
31
|
-
_b)) },
|
|
32
|
-
React.createElement(SideMenuItem, { "aria-label": ariaLabel, icon: icon, caption: caption, subCaption: subCaption, marker: marker, id: id, _isDropdown: true, _isAvatar: _isAvatar })), positions: ['top left'], disableAnimations: true, menuWidth: menuWidth, onOpen: handleOpen, onClose: handleClose }, rest), React.Children.map(children, function (child) {
|
|
18
|
+
var dropdownChildren = useMemo(function () {
|
|
19
|
+
return React.Children.map(children, function (child) {
|
|
33
20
|
// @ts-expect-error: accessing private property
|
|
34
21
|
if (React.isValidElement(child) && (child === null || child === void 0 ? void 0 : child.type.__KONTUR_REACT_UI__) === 'MenuItem') {
|
|
35
22
|
return React.cloneElement(child, {
|
|
@@ -41,7 +28,20 @@ var SideMenuDropdownInner = forwardRef(function (_a, ref) {
|
|
|
41
28
|
});
|
|
42
29
|
}
|
|
43
30
|
return child;
|
|
44
|
-
})
|
|
31
|
+
});
|
|
32
|
+
}, [children, context.toggleIsOpened]);
|
|
33
|
+
return (React.createElement("li", { className: cx(styles.wrapper(), className) },
|
|
34
|
+
React.createElement(DropdownMenu, __assign({ ref: ref, caption: React.createElement("div", { className: cx(styles.label(theme), (_b = {},
|
|
35
|
+
_b[styles.labelTouchScreen(theme)] = context.isTouchScreen,
|
|
36
|
+
_b[styles.labelCollapsed()] = !context.isOpened,
|
|
37
|
+
_b)) },
|
|
38
|
+
React.createElement(SideMenuItem, { "aria-label": ariaLabel, icon: icon, caption: caption, subCaption: subCaption, marker: marker, id: id, _isDropdown: true, _isDropdownOpen: isMenuOpen, _isAvatar: _isAvatar })), positions: ['top left'], disableAnimations: true, menuWidth: menuWidth, onOpen: function () {
|
|
39
|
+
setIsMenuOpen(true);
|
|
40
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
41
|
+
}, onClose: function () {
|
|
42
|
+
setIsMenuOpen(false);
|
|
43
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
44
|
+
} }, rest), dropdownChildren)));
|
|
45
45
|
});
|
|
46
46
|
SideMenuDropdownInner.displayName = 'SideMenuDropdown';
|
|
47
47
|
/**
|
|
@@ -2,20 +2,21 @@ import { __makeTemplateObject } from "tslib";
|
|
|
2
2
|
import { memoizeGetStyles } from '../../lib/theming/ThemeHelpers.js';
|
|
3
3
|
import { transitionDuration } from '../SideMenu/SideMenu.js';
|
|
4
4
|
export var getStyles = memoizeGetStyles(function (_a) {
|
|
5
|
-
var css = _a.css;
|
|
6
|
-
|
|
5
|
+
var css = _a.css, injectGlobal = _a.injectGlobal;
|
|
6
|
+
var _unused = injectGlobal(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n [data-tid='MenuItem']:active {\n background: rgba(0, 0, 0, 0.1) !important;\n transition: background 80ms ease-out;\n }\n "], ["\n [data-tid='MenuItem']:active {\n background: rgba(0, 0, 0, 0.1) !important;\n transition: background 80ms ease-out;\n }\n "])));
|
|
7
|
+
return {
|
|
7
8
|
label: function (t) {
|
|
8
|
-
return css(
|
|
9
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: calc(\n ", " - 2 * ", " - var(--side-menu-footer-trailing-reserved-width, 0px)\n );\n min-width: 0;\n transition: width ", "ms ease-out;\n "], ["\n width: calc(\n ", " - 2 * ", " - var(--side-menu-footer-trailing-reserved-width, 0px)\n );\n min-width: 0;\n transition: width ", "ms ease-out;\n "])), t.sideMenuWidth, t.sideMenuMarginX, transitionDuration);
|
|
9
10
|
},
|
|
10
11
|
labelTouchScreen: function (t) {
|
|
11
|
-
return css(
|
|
12
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n width: calc(\n ", " - 2 *\n ", " - var(--side-menu-footer-trailing-reserved-width, 0px)\n );\n "], ["\n width: calc(\n ", " - 2 *\n ", " - var(--side-menu-footer-trailing-reserved-width, 0px)\n );\n "])), t.sideMenuWidthTouchScreen, t.sideMenuMarginX);
|
|
12
13
|
},
|
|
13
14
|
labelCollapsed: function () {
|
|
14
|
-
return css(
|
|
15
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: 100%;\n "], ["\n width: 100%;\n "])));
|
|
15
16
|
},
|
|
16
17
|
wrapper: function () {
|
|
17
|
-
return css(
|
|
18
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n overflow-x: hidden;\n min-width: 0;\n "], ["\n overflow-x: hidden;\n min-width: 0;\n "])));
|
|
18
19
|
},
|
|
19
|
-
}
|
|
20
|
+
};
|
|
20
21
|
});
|
|
21
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
22
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { __assign, __read, __rest } from "tslib";
|
|
2
|
+
import { getDOMRect } from '@skbkontur/react-ui/lib/dom/getDOMRect';
|
|
3
|
+
import { mergeRefs } from '@skbkontur/react-ui/lib/mergeRefs';
|
|
2
4
|
import { useEmotion, useStyles } from '@skbkontur/react-ui/lib/renderEnvironment';
|
|
3
5
|
import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
|
|
4
|
-
import React, { forwardRef, useContext, useEffect, useState } from 'react';
|
|
6
|
+
import React, { forwardRef, useContext, useEffect, useRef, useState } from 'react';
|
|
5
7
|
import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers.js';
|
|
8
|
+
import { flattenChildren } from '../../lib/utils/scripts.js';
|
|
6
9
|
import { SideMenuDataTids } from '../../SideMenuDataTids.js';
|
|
7
10
|
import { getStyles as getSideMenuStyles } from '../SideMenu/SideMenu.styles.js';
|
|
8
11
|
import { SideMenuContext } from '../SideMenuContext.js';
|
|
@@ -15,8 +18,20 @@ var SideMenuFooterInner = forwardRef(function (_a, ref) {
|
|
|
15
18
|
var cx = useEmotion().cx;
|
|
16
19
|
var styles = useStyles(getStyles);
|
|
17
20
|
var sideMenuStyles = useStyles(getSideMenuStyles);
|
|
21
|
+
var footerRef = useRef(null);
|
|
18
22
|
var _c = __read(useState(false), 2), isFixed = _c[0], setIsFixed = _c[1];
|
|
23
|
+
useEffect(function () {
|
|
24
|
+
var _a;
|
|
25
|
+
if (footerRef.current) {
|
|
26
|
+
(_a = context.setFooterHeight) === null || _a === void 0 ? void 0 : _a.call(context, getDOMRect(footerRef.current).height);
|
|
27
|
+
}
|
|
28
|
+
}, [children, context.isOpened, context.setFooterHeight]);
|
|
19
29
|
var isTabletOrMobile = context.isTablet || context.isMobile;
|
|
30
|
+
var showCollapseToggle = (context.isDesktop || context.isNarrowDesktop) && !context.disableCollapsing;
|
|
31
|
+
var showTrailingItem = showCollapseToggle && context.isOpened;
|
|
32
|
+
var footerItems = flattenChildren(children);
|
|
33
|
+
var trailingItem = showTrailingItem ? footerItems[footerItems.length - 1] : null;
|
|
34
|
+
var leadingItems = trailingItem ? footerItems.slice(0, -1) : footerItems;
|
|
20
35
|
useEffect(function () {
|
|
21
36
|
setIsFixed(!!context.hasScrollBar && !(context.scrollState === 'bottom'));
|
|
22
37
|
}, [context.hasScrollBar, context.scrollState]);
|
|
@@ -24,8 +39,11 @@ var SideMenuFooterInner = forwardRef(function (_a, ref) {
|
|
|
24
39
|
return (React.createElement("footer", __assign({ "data-tid": SideMenuDataTids.footer, "data-visual-state-fixed": isFixed, className: cx(styles.root(theme), (_b = {},
|
|
25
40
|
_b[styles.rootFixed(theme)] = isFixed,
|
|
26
41
|
_b[styles.rootTransitionedTabletAndMobile()] = context.isBeingTransitioned && isTabletOrMobile,
|
|
27
|
-
_b), className), ref: ref }, rest),
|
|
28
|
-
React.createElement("ul", { className: sideMenuStyles.list() },
|
|
42
|
+
_b), className), ref: mergeRefs(footerRef, ref) }, rest),
|
|
43
|
+
leadingItems.length > 0 && React.createElement("ul", { className: cx(sideMenuStyles.list(), styles.list()) }, leadingItems),
|
|
44
|
+
(trailingItem || showCollapseToggle) && (React.createElement("div", { className: cx(styles.trailingRow()) },
|
|
45
|
+
trailingItem && (React.createElement("ul", { className: cx(sideMenuStyles.list(), styles.list(), styles.trailingItem(theme)) }, trailingItem)),
|
|
46
|
+
showCollapseToggle && (React.createElement("span", { ref: context.collapseToggleRef, className: cx(styles.collapseToggleSlot(theme)) }))))));
|
|
29
47
|
}
|
|
30
48
|
return null;
|
|
31
49
|
});
|
|
@@ -1,6 +1,10 @@
|
|
|
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
|
+
list(): string;
|
|
5
|
+
trailingRow(): string;
|
|
6
|
+
trailingItem(t: SideMenuTheme): string;
|
|
7
|
+
collapseToggleSlot(t: SideMenuTheme): string;
|
|
4
8
|
rootFixed(t: SideMenuTheme): string;
|
|
5
9
|
rootTransitionedTabletAndMobile(): string;
|
|
6
10
|
}>;
|
|
@@ -4,14 +4,26 @@ export var getStyles = memoizeGetStyles(function (_a) {
|
|
|
4
4
|
var css = _a.css;
|
|
5
5
|
return ({
|
|
6
6
|
root: function (t) {
|
|
7
|
-
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n flex-grow: 0;\n position: sticky;\n bottom: 0;\n padding-bottom: ", ";\n padding-top: ", ";\n margin: 0 ", ";\n background-color: inherit;\n "], ["\n flex-grow: 0;\n position: sticky;\n bottom: 0;\n padding-bottom: ", ";\n padding-top: ", ";\n margin: 0 ", ";\n background-color: inherit;\n "])), t.sideMenuFooterPaddingBottom, t.sideMenuFooterPaddingTop, t.sideMenuMarginX);
|
|
7
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n flex-grow: 0;\n position: sticky;\n bottom: 0;\n padding-bottom: ", ";\n padding-top: ", ";\n margin: 0 ", ";\n background-color: inherit;\n "], ["\n display: flex;\n flex-direction: column;\n flex-grow: 0;\n position: sticky;\n bottom: 0;\n padding-bottom: ", ";\n padding-top: ", ";\n margin: 0 ", ";\n background-color: inherit;\n "])), t.sideMenuFooterPaddingBottom, t.sideMenuFooterPaddingTop, t.sideMenuMarginX);
|
|
8
|
+
},
|
|
9
|
+
list: function () {
|
|
10
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n min-width: 0;\n "], ["\n display: flex;\n flex-direction: column;\n min-width: 0;\n "])));
|
|
11
|
+
},
|
|
12
|
+
trailingRow: function () {
|
|
13
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n min-width: 0;\n "], ["\n display: flex;\n align-items: center;\n min-width: 0;\n "])));
|
|
14
|
+
},
|
|
15
|
+
trailingItem: function (t) {
|
|
16
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n flex: 1 1 auto;\n min-width: 0;\n --side-menu-footer-trailing-reserved-width: ", ";\n "], ["\n flex: 1 1 auto;\n min-width: 0;\n --side-menu-footer-trailing-reserved-width: ", ";\n "])), t.sideMenuCollapseToggleSize);
|
|
17
|
+
},
|
|
18
|
+
collapseToggleSlot: function (t) {
|
|
19
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n width: ", ";\n height: ", ";\n flex-shrink: 0;\n "], ["\n width: ", ";\n height: ", ";\n flex-shrink: 0;\n "])), t.sideMenuCollapseToggleSize, t.sideMenuCollapseToggleSize);
|
|
8
20
|
},
|
|
9
21
|
rootFixed: function (t) {
|
|
10
|
-
return css(
|
|
22
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n box-shadow: 0 -1px 0 ", ";\n "], ["\n box-shadow: 0 -1px 0 ", ";\n "])), t.sideMenuFooterDividerColor);
|
|
11
23
|
},
|
|
12
24
|
rootTransitionedTabletAndMobile: function () {
|
|
13
|
-
return css(
|
|
25
|
+
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n position: static;\n "], ["\n position: static;\n "])));
|
|
14
26
|
},
|
|
15
27
|
});
|
|
16
28
|
});
|
|
17
|
-
var templateObject_1, templateObject_2, templateObject_3;
|
|
29
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
@@ -7,28 +7,29 @@ import React, { forwardRef, useContext, useEffect, useRef } from 'react';
|
|
|
7
7
|
import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers.js';
|
|
8
8
|
import { SideMenuLogotype } from '../internal/SideMenuLogotype.js';
|
|
9
9
|
import { SideMenuContext } from '../SideMenuContext.js';
|
|
10
|
+
import { separatedShown } from '../state/selectors.js';
|
|
10
11
|
import { getStyles } from './SideMenuHeader.styles.js';
|
|
11
12
|
var SideMenuHeaderInner = forwardRef(function (_a, ref) {
|
|
12
13
|
var _b;
|
|
13
|
-
var _c;
|
|
14
|
-
var className = _a.className, productLogo = _a.productLogo, konturLogo = _a.konturLogo, iconUrl = _a.iconUrl, style = _a.style, _d = _a.withWidget, withWidget = _d === void 0 ? true : _d, dataTid = _a["data-tid"], rest = __rest(_a, ["className", "productLogo", "konturLogo", "iconUrl", "style", "withWidget", 'data-tid']);
|
|
14
|
+
var className = _a.className, productLogo = _a.productLogo, konturLogo = _a.konturLogo, iconUrl = _a.iconUrl, style = _a.style, _c = _a.withWidget, withWidget = _c === void 0 ? true : _c, dataTid = _a["data-tid"], rest = __rest(_a, ["className", "productLogo", "konturLogo", "iconUrl", "style", "withWidget", 'data-tid']);
|
|
15
15
|
var context = useContext(SideMenuContext);
|
|
16
16
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
17
17
|
var headerWrapperRef = useRef(null);
|
|
18
18
|
var isTabletOrMobile = context.isTablet || context.isMobile;
|
|
19
|
+
var isSeparatedMenuShown = separatedShown(context.state);
|
|
19
20
|
useEffect(function () {
|
|
20
21
|
var _a;
|
|
21
22
|
if (headerWrapperRef.current) {
|
|
22
23
|
(_a = context.setHeaderHeight) === null || _a === void 0 ? void 0 : _a.call(context, getDOMRect(headerWrapperRef.current).height);
|
|
23
24
|
}
|
|
24
|
-
}, []);
|
|
25
|
+
}, [context.isOpened]);
|
|
25
26
|
var styles = useStyles(getStyles);
|
|
26
27
|
var cx = useEmotion().cx;
|
|
27
28
|
return (React.createElement("header", { className: cx(styles.root(theme), (_b = {},
|
|
28
|
-
_b[styles.fixedRoot(theme)] =
|
|
29
|
+
_b[styles.fixedRoot(theme)] = !!context.hasScrollBar && !(context.scrollState === 'top'),
|
|
29
30
|
_b[styles.rootTabletAndMobile(theme)] = isTabletOrMobile,
|
|
30
31
|
_b[styles.rootCollapsedTabletAndMobile()] = isTabletOrMobile && !context.isOpened,
|
|
31
|
-
_b[styles.rootWithSeparatedMenuShownMobile(theme)] = context.isOpened && context.isMobile &&
|
|
32
|
+
_b[styles.rootWithSeparatedMenuShownMobile(theme)] = context.isOpened && context.isMobile && isSeparatedMenuShown,
|
|
32
33
|
_b), className), ref: mergeRefs(headerWrapperRef, ref), style: style, "data-tid": dataTid },
|
|
33
34
|
React.createElement(SideMenuLogotype, __assign({ productLogo: productLogo, konturLogo: konturLogo, iconUrl: iconUrl, withWidget: withWidget }, rest))));
|
|
34
35
|
});
|
|
@@ -2,6 +2,7 @@ import { __awaiter, __generator } from "tslib";
|
|
|
2
2
|
import { IconXRegular20 } from '@skbkontur/icons/IconXRegular20';
|
|
3
3
|
import { createFailure, createSuccess, isFailure } from '@skbkontur/operation-result';
|
|
4
4
|
import { Button } from '@skbkontur/react-ui/components/Button/Button';
|
|
5
|
+
import { Center } from '@skbkontur/react-ui/components/Center/Center';
|
|
5
6
|
import { Spinner } from '@skbkontur/react-ui/components/Spinner/Spinner';
|
|
6
7
|
import { useStyles, useEmotion } from '@skbkontur/react-ui/lib/renderEnvironment';
|
|
7
8
|
import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
|
|
@@ -10,11 +11,9 @@ import React, { useContext } from 'react';
|
|
|
10
11
|
import { SideMenuTheme } from '../../internal/themes/SideMenuTheme.js';
|
|
11
12
|
import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers.js';
|
|
12
13
|
import { SideMenuDataTids } from '../../SideMenuDataTids.js';
|
|
13
|
-
import { SideMenuContext } from '../SideMenuContext.js';
|
|
14
14
|
import { BellWidgetError } from './BellWidgetError.js';
|
|
15
15
|
import { getCustomStyles, getStyles } from './BellWidgetView.styles.js';
|
|
16
16
|
import { BELL_SIDE_MENU_DATA_ITEM } from './SideMenuNotifications.js';
|
|
17
|
-
import { getWrapperHeightClass } from './utils/getWrapperHeightClass.js';
|
|
18
17
|
var getBtnTopPosition = function () {
|
|
19
18
|
var _a;
|
|
20
19
|
var bellDropDownItem = document.querySelector("[data-item=\"".concat(BELL_SIDE_MENU_DATA_ITEM, "\"]"));
|
|
@@ -23,8 +22,6 @@ var getBtnTopPosition = function () {
|
|
|
23
22
|
export var BellWidget = function (props) {
|
|
24
23
|
var widgetApi = props.widgetApi, onClose = props.onClose, renderErrorButton = props.renderErrorButton, renderErrorMessage = props.renderErrorMessage, onError = props.onError, redirect = props.redirect;
|
|
25
24
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
26
|
-
var context = useContext(SideMenuContext);
|
|
27
|
-
var isMobile = Boolean(context.isMobile);
|
|
28
25
|
var styles = useStyles(getStyles);
|
|
29
26
|
var customStyles = useStyles(getCustomStyles);
|
|
30
27
|
var cx = useEmotion().cx;
|
|
@@ -75,20 +72,16 @@ export var BellWidget = function (props) {
|
|
|
75
72
|
var buttonCloseTheme = {
|
|
76
73
|
btnBorderRadiusMedium: '20px',
|
|
77
74
|
};
|
|
78
|
-
var wrapperHeightClass =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
btnTopPosition: btnTopPosition,
|
|
83
|
-
customStyles: customStyles,
|
|
84
|
-
});
|
|
85
|
-
return (React.createElement("div", { className: cx(styles.root(), isMobile ? styles.rootMobile() : styles.rootDesktop(), wrapperHeightClass) },
|
|
75
|
+
var wrapperHeightClass = hasCustomWrapperHeight
|
|
76
|
+
? customStyles.customHeight(theme.sideMenuNotificationsWrapperHeight)
|
|
77
|
+
: customStyles.defaultHeight(btnTopPosition);
|
|
78
|
+
return (React.createElement("div", { className: cx(styles.root(), wrapperHeightClass) },
|
|
86
79
|
React.createElement("div", { className: styles.header(), "data-tid": SideMenuDataTids.bellHeader },
|
|
87
80
|
React.createElement("span", { className: styles.headerText() }, "\u0423\u0432\u0435\u0434\u043E\u043C\u043B\u0435\u043D\u0438\u044F"),
|
|
88
81
|
React.createElement(Button, { use: "text", size: "medium", width: 40, icon: React.createElement(IconXRegular20, null), onClick: onClose, theme: buttonCloseTheme, "data-tid": SideMenuDataTids.bellCloseButton, "aria-label": "\u0417\u0430\u043A\u0440\u044B\u0442\u044C \u0443\u0432\u0435\u0434\u043E\u043C\u043B\u0435\u043D\u0438\u044F" })),
|
|
89
82
|
React.createElement(WidgetRenderer, { renderWidget: renderWidget, renderFault: function (_a) {
|
|
90
83
|
var fault = _a.fault, retryRender = _a.retryRender;
|
|
91
84
|
return (React.createElement(BellWidgetError, { renderErrorButton: renderErrorButton, error: fault, renderErrorMessage: renderErrorMessage, retryRender: retryRender }));
|
|
92
|
-
}, loader: React.createElement(
|
|
85
|
+
}, loader: React.createElement(Center, null,
|
|
93
86
|
React.createElement(Spinner, { caption: "\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043C \u0443\u0432\u0435\u0434\u043E\u043C\u043B\u0435\u043D\u0438\u044F..." })) })));
|
|
94
87
|
};
|
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
import * as colors from '@skbkontur/colors/tokens-default/light';
|
|
2
1
|
import { EmptyState } from '@skbkontur/empty-state';
|
|
3
2
|
import { IconArrowUiAuthLoginRegular64 } from '@skbkontur/icons/IconArrowUiAuthLoginRegular64';
|
|
4
3
|
import { IconWarningTriangleSolid64 } from '@skbkontur/icons/IconWarningTriangleSolid64';
|
|
5
|
-
import {
|
|
4
|
+
import { Center } from '@skbkontur/react-ui/components/Center/Center';
|
|
6
5
|
import React from 'react';
|
|
7
|
-
import { getStyles } from './BellWidgetView.styles.js';
|
|
8
6
|
import { getErrorMessages } from './utils/getNotificationsErrorMessages.js';
|
|
9
7
|
export var BellWidgetError = function (_a) {
|
|
10
8
|
var renderErrorButton = _a.renderErrorButton, error = _a.error, renderErrorMessage = _a.renderErrorMessage, retryRender = _a.retryRender;
|
|
11
|
-
var styles = useStyles(getStyles);
|
|
12
9
|
if (renderErrorMessage) {
|
|
13
10
|
return React.createElement(React.Fragment, null, renderErrorMessage(error, retryRender));
|
|
14
11
|
}
|
|
15
12
|
var isNotAuthorizedError = error.type === 'userNotAuthorized';
|
|
16
13
|
var errorButton = renderErrorButton === null || renderErrorButton === void 0 ? void 0 : renderErrorButton(error, retryRender);
|
|
17
14
|
var _b = getErrorMessages(isNotAuthorizedError), titleMessage = _b.titleMessage, errorMessage = _b.errorMessage;
|
|
18
|
-
var icon = isNotAuthorizedError ? (React.createElement(IconArrowUiAuthLoginRegular64, { color:
|
|
19
|
-
return (React.createElement(
|
|
15
|
+
var icon = isNotAuthorizedError ? (React.createElement(IconArrowUiAuthLoginRegular64, { color: "#FCB73E" })) : (React.createElement(IconWarningTriangleSolid64, { color: "#FCB73E" }));
|
|
16
|
+
return (React.createElement(Center, null,
|
|
20
17
|
React.createElement(EmptyState, { use: "status" },
|
|
21
18
|
React.createElement(EmptyState.Header, { icon: icon }, titleMessage),
|
|
22
19
|
React.createElement(EmptyState.Body, null, errorMessage),
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { type Emotion } from '../../lib/theming/ThemeHelpers.js';
|
|
2
2
|
export declare const getStyles: import("../../lib/theming/ThemeHelpers.js").StylesGetter<{
|
|
3
3
|
root(): string;
|
|
4
|
-
rootMobile(): string;
|
|
5
|
-
rootDesktop(): string;
|
|
6
4
|
widgetWrapper(): string;
|
|
7
|
-
centeredContent(): string;
|
|
8
5
|
header(): string;
|
|
9
6
|
headerText(): string;
|
|
10
7
|
}>;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
customHeight: (value?: string) => string;
|
|
8
|
+
interface CustomStyles {
|
|
9
|
+
defaultHeight: (offsetTop: number) => string;
|
|
10
|
+
customHeight: (value: string) => string;
|
|
15
11
|
}
|
|
16
12
|
export declare const getCustomStyles: ({ css }: Emotion) => CustomStyles;
|
|
13
|
+
export {};
|
|
@@ -4,42 +4,31 @@ export var getStyles = memoizeGetStyles(function (_a) {
|
|
|
4
4
|
var css = _a.css;
|
|
5
5
|
return ({
|
|
6
6
|
root: function () {
|
|
7
|
-
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n min-height: 400px;\n max-height: 784px;\n max-width: 100vw;\n "], ["\n display: flex;\n flex-direction: column;\n min-height: 400px;\n max-height: 784px;\n max-width: 100vw;\n "])));
|
|
8
|
-
},
|
|
9
|
-
rootMobile: function () {
|
|
10
|
-
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: 100%;\n "], ["\n width: 100%;\n "])));
|
|
11
|
-
},
|
|
12
|
-
rootDesktop: function () {
|
|
13
|
-
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n width: 448px;\n "], ["\n width: 448px;\n "])));
|
|
7
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n min-height: 400px;\n max-height: 784px;\n width: 100%;\n max-width: 100vw;\n\n @media (min-width: 768px) {\n width: 448px;\n }\n "], ["\n display: flex;\n flex-direction: column;\n min-height: 400px;\n max-height: 784px;\n width: 100%;\n max-width: 100vw;\n\n @media (min-width: 768px) {\n width: 448px;\n }\n "])));
|
|
14
8
|
},
|
|
15
9
|
widgetWrapper: function () {
|
|
16
|
-
return css(
|
|
17
|
-
},
|
|
18
|
-
centeredContent: function () {
|
|
19
|
-
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n display: flex;\n flex: 1;\n min-height: 0;\n overflow: auto;\n align-items: center;\n justify-content: center;\n "], ["\n display: flex;\n flex: 1;\n min-height: 0;\n overflow: auto;\n align-items: center;\n justify-content: center;\n "])));
|
|
10
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n min-height: 0;\n flex-grow: 1;\n "], ["\n min-height: 0;\n flex-grow: 1;\n "])));
|
|
20
11
|
},
|
|
21
12
|
header: function () {
|
|
22
|
-
return css(
|
|
13
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex;\n padding: 6px 6px 0 20px;\n align-items: center;\n justify-content: space-between;\n "], ["\n display: flex;\n padding: 6px 6px 0 20px;\n align-items: center;\n justify-content: space-between;\n "])));
|
|
23
14
|
},
|
|
24
15
|
headerText: function () {
|
|
25
|
-
return css(
|
|
16
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-size: 18px;\n line-height: 24px;\n font-weight: 700;\n "], ["\n font-size: 18px;\n line-height: 24px;\n font-weight: 700;\n "])));
|
|
26
17
|
},
|
|
27
18
|
});
|
|
28
19
|
});
|
|
29
20
|
export var getCustomStyles = function (_a) {
|
|
30
21
|
var css = _a.css;
|
|
31
22
|
return ({
|
|
32
|
-
|
|
23
|
+
defaultHeight: function (offsetTop) {
|
|
24
|
+
if (offsetTop === void 0) { offsetTop = 0; }
|
|
33
25
|
var offsetBottom = '20px';
|
|
34
|
-
return css(
|
|
35
|
-
},
|
|
36
|
-
defaultHeightMobile: function (mobilePopupHeightOffset) {
|
|
37
|
-
return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n height: calc(100vh - (", "));\n max-height: calc(100vh - (", "));\n\n @supports (height: 100dvh) {\n height: calc(100dvh - (", "));\n max-height: calc(100dvh - (", "));\n }\n "], ["\n height: calc(100vh - (", "));\n max-height: calc(100vh - (", "));\n\n @supports (height: 100dvh) {\n height: calc(100dvh - (", "));\n max-height: calc(100dvh - (", "));\n }\n "])), mobilePopupHeightOffset, mobilePopupHeightOffset, mobilePopupHeightOffset, mobilePopupHeightOffset);
|
|
26
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n height: calc(100vh - ", "px - ", ");\n "], ["\n height: calc(100vh - ", "px - ", ");\n "])), offsetTop, offsetBottom);
|
|
38
27
|
},
|
|
39
28
|
customHeight: function (value) {
|
|
40
29
|
if (value === void 0) { value = ''; }
|
|
41
|
-
return css(
|
|
30
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n height: ", ";\n "], ["\n height: ", ";\n "])), value);
|
|
42
31
|
},
|
|
43
32
|
});
|
|
44
33
|
};
|
|
45
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6
|
|
34
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
|
|
@@ -13,6 +13,7 @@ var SideMenuSubItemHeaderInner = forwardRef(function (_a, ref) {
|
|
|
13
13
|
var cx = useEmotion().cx;
|
|
14
14
|
var styles = useStyles(getStyles);
|
|
15
15
|
return (React.createElement("p", __assign({ className: cx(styles.root(theme), (_b = {},
|
|
16
|
+
_b[styles.rootInDropdown()] = !context.isOpened && !context.isSeparatedMenu,
|
|
16
17
|
_b[styles.rootInSeparatedSubMenu()] = context.isSeparatedMenu,
|
|
17
18
|
_b), className), ref: ref }, rest), children));
|
|
18
19
|
});
|
|
@@ -6,9 +6,12 @@ export var getStyles = memoizeGetStyles(function (_a) {
|
|
|
6
6
|
root: function (t) {
|
|
7
7
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n font-size: ", ";\n color: ", ";\n padding: ", ";\n margin: 0;\n "], ["\n font-size: ", ";\n color: ", ";\n padding: ", ";\n margin: 0;\n "])), t.sideMenuSubItemHeaderFontSize, t.sideMenuSubItemHeaderColor, t.sideMenuSubItemHeaderPadding);
|
|
8
8
|
},
|
|
9
|
+
rootInDropdown: function () {
|
|
10
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding: 12px 8px 4px 8px;\n "], ["\n padding: 12px 8px 4px 8px;\n "])));
|
|
11
|
+
},
|
|
9
12
|
rootInSeparatedSubMenu: function () {
|
|
10
|
-
return css(
|
|
13
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding-left: 8px;\n "], ["\n padding-left: 8px;\n "])));
|
|
11
14
|
},
|
|
12
15
|
});
|
|
13
16
|
});
|
|
14
|
-
var templateObject_1, templateObject_2;
|
|
17
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { SideMenuLinkProps } from '../SideMenuLink/SideMenuLink.js';
|
|
3
|
-
export interface SideMenuSubLinkProps<T = string> extends Omit<SideMenuLinkProps<T>, 'icon'>, Partial<Pick<SideMenuLinkProps, 'icon'>> {
|
|
3
|
+
export interface SideMenuSubLinkProps<T = string> extends Omit<SideMenuLinkProps<T>, 'icon' | 'hint'>, Partial<Pick<SideMenuLinkProps, 'icon'>> {
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
6
|
* Ссылка в подменю для `SideMenu`
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { CommonClickableElementProps } from './ClickableElement.js';
|
|
3
|
-
export
|
|
4
|
-
href?: string;
|
|
5
|
-
}
|
|
3
|
+
export type BackButtonProps = Pick<CommonClickableElementProps, 'caption' | 'id'>;
|
|
6
4
|
declare const BackButtonWithStaticFields: React.ForwardRefExoticComponent<BackButtonProps & React.RefAttributes<HTMLButtonElement>> & {
|
|
7
5
|
__KONTUR_REACT_UI__: string;
|
|
8
6
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IconArrowALeftRegular20 } from '@skbkontur/icons/IconArrowALeftRegular20';
|
|
2
2
|
import React, { forwardRef, useContext } from 'react';
|
|
3
3
|
import { SideMenuDataTids } from '../../SideMenuDataTids.js';
|
|
4
|
-
import { navigationAttributeBackButton } from '../
|
|
4
|
+
import { navigationAttributeBackButton } from '../navigationAttributes.js';
|
|
5
5
|
import { SideMenuContext } from '../SideMenuContext.js';
|
|
6
6
|
import { SideMenuItem } from '../SideMenuItem/SideMenuItem.js';
|
|
7
7
|
/**
|
|
@@ -14,8 +14,9 @@ var BackButton = forwardRef(function (_a, ref) {
|
|
|
14
14
|
var caption = _a.caption, id = _a.id;
|
|
15
15
|
var context = useContext(SideMenuContext);
|
|
16
16
|
var handleClick = function () {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
if (id !== undefined) {
|
|
18
|
+
context.dispatch({ type: 'SELECT', id: id, isButton: false });
|
|
19
|
+
}
|
|
19
20
|
};
|
|
20
21
|
return (React.createElement(SideMenuItem, (_b = { ref: ref, "data-tid": SideMenuDataTids.backButton, icon: React.createElement(IconArrowALeftRegular20, null), caption: caption, onClick: handleClick, _isSubMenu: true, _isBackButton: true }, _b[navigationAttributeBackButton] = '', _b)));
|
|
21
22
|
});
|
|
@@ -19,11 +19,21 @@ export interface CommonClickableElementProps extends CommonProps {
|
|
|
19
19
|
disabled?: boolean;
|
|
20
20
|
/** Отключает перенос строки у заголовка элемента, вместо этого он будет обрезаться многоточием. */
|
|
21
21
|
noWrap?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Текст всплывающей подсказки (`Hint`) над элементом. Показывается только в свёрнутом
|
|
24
|
+
* меню (наведение мыши); в развёрнутом — подавляется, т.к. подпись и так видна.
|
|
25
|
+
* По умолчанию берётся из `caption`. Чтобы скрыть подсказку, передайте `hint={null}`.
|
|
26
|
+
* Для доступности в свёрнутом состоянии передавайте также `aria-label` — `hint` носит
|
|
27
|
+
* визуальный характер и не подставляется в `aria-label` автоматически.
|
|
28
|
+
*/
|
|
29
|
+
hint?: ReactNode;
|
|
22
30
|
/** @ignore */
|
|
23
31
|
_isSubMenu?: boolean;
|
|
24
32
|
/** @ignore */
|
|
25
33
|
_isDropdown?: boolean;
|
|
26
34
|
/** @ignore */
|
|
35
|
+
_isDropdownOpen?: boolean;
|
|
36
|
+
/** @ignore */
|
|
27
37
|
_isAvatar?: boolean;
|
|
28
38
|
/** @ignore */
|
|
29
39
|
_isBackButton?: boolean;
|
|
@@ -37,7 +47,13 @@ export interface ClickableElementProps extends CommonClickableElementProps {
|
|
|
37
47
|
onFocus?: React.EventHandler<React.FocusEvent>;
|
|
38
48
|
onBlur?: React.EventHandler<React.FocusEvent>;
|
|
39
49
|
}
|
|
40
|
-
|
|
50
|
+
interface ClickableElementWithHintProps {
|
|
51
|
+
hint?: ReactNode;
|
|
52
|
+
isOpened?: boolean;
|
|
53
|
+
children: React.ReactElement;
|
|
54
|
+
}
|
|
55
|
+
declare const ClickableElementWithHint: ({ hint, isOpened, children }: ClickableElementWithHintProps) => JSX.Element;
|
|
56
|
+
declare const ClickableElementWithStaticFields: React.ForwardRefExoticComponent<ClickableElementProps & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>> & {
|
|
41
57
|
__KONTUR_REACT_UI__: string;
|
|
42
58
|
};
|
|
43
|
-
export { ClickableElementWithStaticFields as ClickableElement };
|
|
59
|
+
export { ClickableElementWithStaticFields as ClickableElement, ClickableElementWithHint };
|