@skbkontur/side-menu 4.0.10-beta.0 → 4.0.10

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.
Files changed (79) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +11 -38
  3. package/SideMenuDataTids.d.ts +1 -2
  4. package/SideMenuDataTids.js +1 -2
  5. package/hooks/useMemoIcon.d.ts +2 -1
  6. package/hooks/useMemoIcon.js +9 -0
  7. package/internal/themes/SideMenuTheme.d.ts +7 -4
  8. package/internal/themes/SideMenuTheme.js +23 -6
  9. package/lib/theming/ThemeHelpers.js +4 -0
  10. package/lib/utils/scripts.d.ts +0 -1
  11. package/lib/utils/scripts.js +0 -9
  12. package/package.json +1 -1
  13. package/src/Navigation.d.ts +53 -0
  14. package/src/Navigation.js +194 -0
  15. package/src/SideMenu/SideMenu.d.ts +4 -7
  16. package/src/SideMenu/SideMenu.js +178 -148
  17. package/src/SideMenu/SideMenu.styles.js +2 -2
  18. package/src/SideMenuAvatar/SideMenuAvatar.js +2 -11
  19. package/src/SideMenuContext.d.ts +9 -16
  20. package/src/SideMenuContext.js +1 -6
  21. package/src/SideMenuDropdown/SideMenuDropdown.js +18 -11
  22. package/src/SideMenuDropdown/SideMenuDropdown.styles.js +3 -3
  23. package/src/SideMenuFooter/SideMenuFooter.js +3 -15
  24. package/src/SideMenuFooter/SideMenuFooter.styles.d.ts +0 -4
  25. package/src/SideMenuFooter/SideMenuFooter.styles.js +4 -16
  26. package/src/SideMenuHeader/SideMenuHeader.js +3 -4
  27. package/src/SideMenuNotifications/BellWidget.js +13 -6
  28. package/src/SideMenuNotifications/BellWidgetError.js +6 -3
  29. package/src/SideMenuNotifications/BellWidgetView.styles.d.ts +7 -4
  30. package/src/SideMenuNotifications/BellWidgetView.styles.js +20 -9
  31. package/src/SideMenuNotifications/utils/getWrapperHeightClass.d.ts +11 -0
  32. package/src/SideMenuNotifications/utils/getWrapperHeightClass.js +10 -0
  33. package/src/SideMenuSubItem/SideMenuSubItem.d.ts +1 -1
  34. package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.js +0 -1
  35. package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.d.ts +0 -1
  36. package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.js +2 -5
  37. package/src/SideMenuSubLink/SideMenuSubLink.d.ts +1 -1
  38. package/src/Tree.d.ts +17 -0
  39. package/src/Tree.js +135 -0
  40. package/src/internal/BackButton.d.ts +3 -1
  41. package/src/internal/BackButton.js +3 -4
  42. package/src/internal/ClickableElement.d.ts +1 -8
  43. package/src/internal/ClickableElement.js +67 -125
  44. package/src/internal/ClickableElement.styles.d.ts +0 -1
  45. package/src/internal/ClickableElement.styles.js +3 -6
  46. package/src/internal/ItemContent/Caption.d.ts +1 -1
  47. package/src/internal/ItemContent/Caption.js +26 -9
  48. package/src/internal/ItemContent/Icon.js +2 -3
  49. package/src/internal/ItemContent/Icon.styles.d.ts +0 -1
  50. package/src/internal/ItemContent/Icon.styles.js +3 -6
  51. package/src/internal/ItemContent/ItemContent.js +5 -17
  52. package/src/internal/ItemContent/ItemContent.styles.d.ts +0 -1
  53. package/src/internal/ItemContent/ItemContent.styles.js +4 -7
  54. package/src/internal/RightBorder.d.ts +9 -0
  55. package/src/internal/RightBorder.js +37 -0
  56. package/src/internal/{CollapseToggle.styles.d.ts → RightBorder.styles.d.ts} +1 -0
  57. package/src/internal/RightBorder.styles.js +14 -0
  58. package/src/internal/SeparatedSubMenu.js +9 -7
  59. package/src/internal/SeparatedSubMenu.styles.d.ts +3 -0
  60. package/src/internal/SeparatedSubMenu.styles.js +15 -6
  61. package/src/internal/SideMenuLogotype.js +8 -10
  62. package/src/internal/SubMenu.js +2 -3
  63. package/hooks/useNodeState.d.ts +0 -7
  64. package/hooks/useNodeState.js +0 -12
  65. package/hooks/useSideMenuReducer.d.ts +0 -13
  66. package/hooks/useSideMenuReducer.js +0 -23
  67. package/src/internal/CollapseToggle.d.ts +0 -1
  68. package/src/internal/CollapseToggle.js +0 -27
  69. package/src/internal/CollapseToggle.styles.js +0 -12
  70. package/src/internal/NarrowAccordionDropdown.d.ts +0 -13
  71. package/src/internal/NarrowAccordionDropdown.js +0 -34
  72. package/src/navigationAttributes.d.ts +0 -3
  73. package/src/navigationAttributes.js +0 -3
  74. package/src/state/reducer.d.ts +0 -2
  75. package/src/state/reducer.js +0 -258
  76. package/src/state/selectors.d.ts +0 -16
  77. package/src/state/selectors.js +0 -71
  78. package/src/state/types.d.ts +0 -59
  79. package/src/state/types.js +0 -17
@@ -3,27 +3,20 @@ import { useEmotion, useStyles } from '@skbkontur/react-ui/lib/renderEnvironment
3
3
  import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
4
4
  import React, { forwardRef, useContext, useEffect, useState } from 'react';
5
5
  import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers.js';
6
- import { flattenChildren } from '../../lib/utils/scripts.js';
7
6
  import { SideMenuDataTids } from '../../SideMenuDataTids.js';
8
- import { CollapseToggle } from '../internal/CollapseToggle.js';
9
7
  import { getStyles as getSideMenuStyles } from '../SideMenu/SideMenu.styles.js';
10
8
  import { SideMenuContext } from '../SideMenuContext.js';
11
9
  import { getStyles } from './SideMenuFooter.styles.js';
12
10
  var SideMenuFooterInner = forwardRef(function (_a, ref) {
13
- var _b, _c;
11
+ var _b;
14
12
  var className = _a.className, children = _a.children, rest = __rest(_a, ["className", "children"]);
15
13
  var context = useContext(SideMenuContext);
16
14
  var theme = getSideMenuTheme(useContext(ThemeContext));
17
15
  var cx = useEmotion().cx;
18
16
  var styles = useStyles(getStyles);
19
17
  var sideMenuStyles = useStyles(getSideMenuStyles);
20
- var _d = __read(useState(false), 2), isFixed = _d[0], setIsFixed = _d[1];
18
+ var _c = __read(useState(false), 2), isFixed = _c[0], setIsFixed = _c[1];
21
19
  var isTabletOrMobile = context.isTablet || context.isMobile;
22
- var showCollapseToggle = (context.isDesktop || context.isNarrowDesktop) && !context.disableCollapsing;
23
- var showTrailingItem = showCollapseToggle && context.isOpened;
24
- var footerItems = flattenChildren(children);
25
- var trailingItem = showTrailingItem ? footerItems[footerItems.length - 1] : null;
26
- var leadingItems = trailingItem ? footerItems.slice(0, -1) : footerItems;
27
20
  useEffect(function () {
28
21
  setIsFixed(!!context.hasScrollBar && !(context.scrollState === 'bottom'));
29
22
  }, [context.hasScrollBar, context.scrollState]);
@@ -32,12 +25,7 @@ var SideMenuFooterInner = forwardRef(function (_a, ref) {
32
25
  _b[styles.rootFixed(theme)] = isFixed,
33
26
  _b[styles.rootTransitionedTabletAndMobile()] = context.isBeingTransitioned && isTabletOrMobile,
34
27
  _b), className), ref: ref }, rest),
35
- leadingItems.length > 0 && React.createElement("ul", { className: cx(sideMenuStyles.list(), styles.list()) }, leadingItems),
36
- (trailingItem || showCollapseToggle) && (React.createElement("div", { className: cx(styles.trailingRow(), (_c = {},
37
- _c[styles.trailingRowCorner()] = !trailingItem,
38
- _c)) },
39
- trailingItem && (React.createElement("ul", { className: cx(sideMenuStyles.list(), styles.list(), styles.trailingItem(theme)) }, trailingItem)),
40
- showCollapseToggle && React.createElement(CollapseToggle, null)))));
28
+ React.createElement("ul", { className: sideMenuStyles.list() }, children)));
41
29
  }
42
30
  return null;
43
31
  });
@@ -1,10 +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
- list(): string;
5
- trailingRow(): string;
6
- trailingRowCorner(): string;
7
- trailingItem(t: SideMenuTheme): string;
8
4
  rootFixed(t: SideMenuTheme): string;
9
5
  rootTransitionedTabletAndMobile(): string;
10
6
  }>;
@@ -4,26 +4,14 @@ 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 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
- trailingRowCorner: function () {
16
- return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n justify-content: flex-end;\n "], ["\n justify-content: flex-end;\n "])));
17
- },
18
- trailingItem: function (t) {
19
- return css(templateObject_5 || (templateObject_5 = __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);
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);
20
8
  },
21
9
  rootFixed: function (t) {
22
- return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n box-shadow: 0 -1px 0 ", ";\n "], ["\n box-shadow: 0 -1px 0 ", ";\n "])), t.sideMenuFooterDividerColor);
10
+ return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n box-shadow: 0 -1px 0 ", ";\n "], ["\n box-shadow: 0 -1px 0 ", ";\n "])), t.sideMenuFooterDividerColor);
23
11
  },
24
12
  rootTransitionedTabletAndMobile: function () {
25
- return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n position: static;\n "], ["\n position: static;\n "])));
13
+ return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: static;\n "], ["\n position: static;\n "])));
26
14
  },
27
15
  });
28
16
  });
29
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
17
+ var templateObject_1, templateObject_2, templateObject_3;
@@ -7,16 +7,15 @@ 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';
11
10
  import { getStyles } from './SideMenuHeader.styles.js';
12
11
  var SideMenuHeaderInner = forwardRef(function (_a, ref) {
13
12
  var _b;
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']);
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']);
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);
20
19
  useEffect(function () {
21
20
  var _a;
22
21
  if (headerWrapperRef.current) {
@@ -29,7 +28,7 @@ var SideMenuHeaderInner = forwardRef(function (_a, ref) {
29
28
  _b[styles.fixedRoot(theme)] = context.isOpened && !!context.hasScrollBar && !(context.scrollState === 'top'),
30
29
  _b[styles.rootTabletAndMobile(theme)] = isTabletOrMobile,
31
30
  _b[styles.rootCollapsedTabletAndMobile()] = isTabletOrMobile && !context.isOpened,
32
- _b[styles.rootWithSeparatedMenuShownMobile(theme)] = context.isOpened && context.isMobile && isSeparatedMenuShown,
31
+ _b[styles.rootWithSeparatedMenuShownMobile(theme)] = context.isOpened && context.isMobile && ((_c = context.navigation) === null || _c === void 0 ? void 0 : _c.isSeparatedMenuShown),
33
32
  _b), className), ref: mergeRefs(headerWrapperRef, ref), style: style, "data-tid": dataTid },
34
33
  React.createElement(SideMenuLogotype, __assign({ productLogo: productLogo, konturLogo: konturLogo, iconUrl: iconUrl, withWidget: withWidget }, rest))));
35
34
  });
@@ -2,7 +2,6 @@ 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';
6
5
  import { Spinner } from '@skbkontur/react-ui/components/Spinner/Spinner';
7
6
  import { useStyles, useEmotion } from '@skbkontur/react-ui/lib/renderEnvironment';
8
7
  import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
@@ -11,9 +10,11 @@ import React, { useContext } from 'react';
11
10
  import { SideMenuTheme } from '../../internal/themes/SideMenuTheme.js';
12
11
  import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers.js';
13
12
  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';
17
18
  var getBtnTopPosition = function () {
18
19
  var _a;
19
20
  var bellDropDownItem = document.querySelector("[data-item=\"".concat(BELL_SIDE_MENU_DATA_ITEM, "\"]"));
@@ -22,6 +23,8 @@ var getBtnTopPosition = function () {
22
23
  export var BellWidget = function (props) {
23
24
  var widgetApi = props.widgetApi, onClose = props.onClose, renderErrorButton = props.renderErrorButton, renderErrorMessage = props.renderErrorMessage, onError = props.onError, redirect = props.redirect;
24
25
  var theme = getSideMenuTheme(useContext(ThemeContext));
26
+ var context = useContext(SideMenuContext);
27
+ var isMobile = Boolean(context.isMobile);
25
28
  var styles = useStyles(getStyles);
26
29
  var customStyles = useStyles(getCustomStyles);
27
30
  var cx = useEmotion().cx;
@@ -72,16 +75,20 @@ export var BellWidget = function (props) {
72
75
  var buttonCloseTheme = {
73
76
  btnBorderRadiusMedium: '20px',
74
77
  };
75
- var wrapperHeightClass = hasCustomWrapperHeight
76
- ? customStyles.customHeight(theme.sideMenuNotificationsWrapperHeight)
77
- : customStyles.defaultHeight(btnTopPosition);
78
- return (React.createElement("div", { className: cx(styles.root(), wrapperHeightClass) },
78
+ var wrapperHeightClass = getWrapperHeightClass({
79
+ hasCustomWrapperHeight: hasCustomWrapperHeight,
80
+ theme: theme,
81
+ isMobile: isMobile,
82
+ btnTopPosition: btnTopPosition,
83
+ customStyles: customStyles,
84
+ });
85
+ return (React.createElement("div", { className: cx(styles.root(), isMobile ? styles.rootMobile() : styles.rootDesktop(), wrapperHeightClass) },
79
86
  React.createElement("div", { className: styles.header(), "data-tid": SideMenuDataTids.bellHeader },
80
87
  React.createElement("span", { className: styles.headerText() }, "\u0423\u0432\u0435\u0434\u043E\u043C\u043B\u0435\u043D\u0438\u044F"),
81
88
  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" })),
82
89
  React.createElement(WidgetRenderer, { renderWidget: renderWidget, renderFault: function (_a) {
83
90
  var fault = _a.fault, retryRender = _a.retryRender;
84
91
  return (React.createElement(BellWidgetError, { renderErrorButton: renderErrorButton, error: fault, renderErrorMessage: renderErrorMessage, retryRender: retryRender }));
85
- }, loader: React.createElement(Center, null,
92
+ }, loader: React.createElement("div", { className: styles.centeredContent() },
86
93
  React.createElement(Spinner, { caption: "\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043C \u0443\u0432\u0435\u0434\u043E\u043C\u043B\u0435\u043D\u0438\u044F..." })) })));
87
94
  };
@@ -1,19 +1,22 @@
1
+ import * as colors from '@skbkontur/colors/tokens-default/light';
1
2
  import { EmptyState } from '@skbkontur/empty-state';
2
3
  import { IconArrowUiAuthLoginRegular64 } from '@skbkontur/icons/IconArrowUiAuthLoginRegular64';
3
4
  import { IconWarningTriangleSolid64 } from '@skbkontur/icons/IconWarningTriangleSolid64';
4
- import { Center } from '@skbkontur/react-ui/components/Center/Center';
5
+ import { useStyles } from '@skbkontur/react-ui/lib/renderEnvironment';
5
6
  import React from 'react';
7
+ import { getStyles } from './BellWidgetView.styles.js';
6
8
  import { getErrorMessages } from './utils/getNotificationsErrorMessages.js';
7
9
  export var BellWidgetError = function (_a) {
8
10
  var renderErrorButton = _a.renderErrorButton, error = _a.error, renderErrorMessage = _a.renderErrorMessage, retryRender = _a.retryRender;
11
+ var styles = useStyles(getStyles);
9
12
  if (renderErrorMessage) {
10
13
  return React.createElement(React.Fragment, null, renderErrorMessage(error, retryRender));
11
14
  }
12
15
  var isNotAuthorizedError = error.type === 'userNotAuthorized';
13
16
  var errorButton = renderErrorButton === null || renderErrorButton === void 0 ? void 0 : renderErrorButton(error, retryRender);
14
17
  var _b = getErrorMessages(isNotAuthorizedError), titleMessage = _b.titleMessage, errorMessage = _b.errorMessage;
15
- var icon = isNotAuthorizedError ? (React.createElement(IconArrowUiAuthLoginRegular64, { color: "#FCB73E" })) : (React.createElement(IconWarningTriangleSolid64, { color: "#FCB73E" }));
16
- return (React.createElement(Center, null,
18
+ var icon = isNotAuthorizedError ? (React.createElement(IconArrowUiAuthLoginRegular64, { color: colors.shapeBoldWarning })) : (React.createElement(IconWarningTriangleSolid64, { color: colors.shapeBoldWarning }));
19
+ return (React.createElement("div", { className: styles.centeredContent() },
17
20
  React.createElement(EmptyState, { use: "status" },
18
21
  React.createElement(EmptyState.Header, { icon: icon }, titleMessage),
19
22
  React.createElement(EmptyState.Body, null, errorMessage),
@@ -1,13 +1,16 @@
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;
4
6
  widgetWrapper(): string;
7
+ centeredContent(): string;
5
8
  header(): string;
6
9
  headerText(): string;
7
10
  }>;
8
- interface CustomStyles {
9
- defaultHeight: (offsetTop: number) => string;
10
- customHeight: (value: string) => string;
11
+ export interface CustomStyles {
12
+ defaultHeightDesktop: (offsetTop: number) => string;
13
+ defaultHeightMobile: (mobilePopupHeightOffset: string) => string;
14
+ customHeight: (value?: string) => string;
11
15
  }
12
16
  export declare const getCustomStyles: ({ css }: Emotion) => CustomStyles;
13
- export {};
@@ -4,31 +4,42 @@ 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 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 "])));
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 "])));
8
14
  },
9
15
  widgetWrapper: function () {
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 "])));
16
+ return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n min-height: 0;\n flex-grow: 1;\n "], ["\n min-height: 0;\n flex-grow: 1;\n "])));
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 "])));
11
20
  },
12
21
  header: function () {
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 "])));
22
+ return css(templateObject_6 || (templateObject_6 = __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 "])));
14
23
  },
15
24
  headerText: function () {
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 "])));
25
+ return css(templateObject_7 || (templateObject_7 = __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 "])));
17
26
  },
18
27
  });
19
28
  });
20
29
  export var getCustomStyles = function (_a) {
21
30
  var css = _a.css;
22
31
  return ({
23
- defaultHeight: function (offsetTop) {
24
- if (offsetTop === void 0) { offsetTop = 0; }
32
+ defaultHeightDesktop: function (offsetTop) {
25
33
  var offsetBottom = '20px';
26
- return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n height: calc(100vh - ", "px - ", ");\n "], ["\n height: calc(100vh - ", "px - ", ");\n "])), offsetTop, offsetBottom);
34
+ return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n height: calc(100vh - ", "px - ", ");\n "], ["\n height: calc(100vh - ", "px - ", ");\n "])), offsetTop, offsetBottom);
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);
27
38
  },
28
39
  customHeight: function (value) {
29
40
  if (value === void 0) { value = ''; }
30
- return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n height: ", ";\n "], ["\n height: ", ";\n "])), value);
41
+ return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n height: ", ";\n "], ["\n height: ", ";\n "])), value);
31
42
  },
32
43
  });
33
44
  };
34
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
45
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
@@ -0,0 +1,11 @@
1
+ import type { SideMenuTheme } from '../../../lib/theming/ThemeTypes.js';
2
+ import type { CustomStyles } from '../BellWidgetView.styles.js';
3
+ interface GetWrapperHeightClassParameters {
4
+ hasCustomWrapperHeight: boolean;
5
+ theme: SideMenuTheme;
6
+ isMobile: boolean;
7
+ btnTopPosition: number;
8
+ customStyles: CustomStyles;
9
+ }
10
+ export declare const getWrapperHeightClass: ({ hasCustomWrapperHeight, theme, isMobile, btnTopPosition, customStyles, }: GetWrapperHeightClassParameters) => string;
11
+ export {};
@@ -0,0 +1,10 @@
1
+ export var getWrapperHeightClass = function (_a) {
2
+ var hasCustomWrapperHeight = _a.hasCustomWrapperHeight, theme = _a.theme, isMobile = _a.isMobile, btnTopPosition = _a.btnTopPosition, customStyles = _a.customStyles;
3
+ if (hasCustomWrapperHeight) {
4
+ return customStyles.customHeight(theme.sideMenuNotificationsWrapperHeight);
5
+ }
6
+ if (isMobile) {
7
+ return customStyles.defaultHeightMobile(theme.sideMenuNotificationsMobilePopupHeightOffset);
8
+ }
9
+ return customStyles.defaultHeightDesktop(btnTopPosition);
10
+ };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { SideMenuItemProps } from '../SideMenuItem/SideMenuItem.js';
3
- export interface SideMenuSubItemProps extends Omit<SideMenuItemProps, 'icon' | 'hint'>, Partial<Pick<SideMenuItemProps, 'icon'>> {
3
+ export interface SideMenuSubItemProps extends Omit<SideMenuItemProps, 'icon'>, Partial<Pick<SideMenuItemProps, 'icon'>> {
4
4
  }
5
5
  /**
6
6
  * Элемент списка второго уровня
@@ -13,7 +13,6 @@ 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,
17
16
  _b[styles.rootInSeparatedSubMenu()] = context.isSeparatedMenu,
18
17
  _b), className), ref: ref }, rest), children));
19
18
  });
@@ -1,6 +1,5 @@
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
- rootInDropdown(): string;
5
4
  rootInSeparatedSubMenu(): string;
6
5
  }>;
@@ -6,12 +6,9 @@ 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
- },
12
9
  rootInSeparatedSubMenu: function () {
13
- return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding-left: 8px;\n "], ["\n padding-left: 8px;\n "])));
10
+ return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding-left: 8px;\n "], ["\n padding-left: 8px;\n "])));
14
11
  },
15
12
  });
16
13
  });
17
- var templateObject_1, templateObject_2, templateObject_3;
14
+ var templateObject_1, templateObject_2;
@@ -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' | 'hint'>, Partial<Pick<SideMenuLinkProps, 'icon'>> {
3
+ export interface SideMenuSubLinkProps<T = string> extends Omit<SideMenuLinkProps<T>, 'icon'>, Partial<Pick<SideMenuLinkProps, 'icon'>> {
4
4
  }
5
5
  /**
6
6
  * Ссылка в подменю для `SideMenu`
package/src/Tree.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ import type { NavigableElement } from './Navigation.js';
2
+ export declare class TreeNode {
3
+ id: string;
4
+ value: NavigableElement | null;
5
+ parent: TreeNode | null;
6
+ children: TreeNode[];
7
+ constructor(id: string, value?: NavigableElement | null, parent?: TreeNode | null);
8
+ get hasChildren(): boolean;
9
+ }
10
+ export declare class Tree {
11
+ private root;
12
+ constructor(id: string, value?: NavigableElement | null);
13
+ preOrderTraversal(node?: TreeNode): Generator<TreeNode, void, undefined>;
14
+ insert(parentId: string, id: string | undefined | null, value?: NavigableElement | null): boolean;
15
+ remove(id: string): boolean;
16
+ find(id?: string | null): TreeNode | undefined;
17
+ }
package/src/Tree.js ADDED
@@ -0,0 +1,135 @@
1
+ import { __generator, __values } from "tslib";
2
+ var TreeNode = /** @class */ (function () {
3
+ function TreeNode(id, value, parent) {
4
+ if (value === void 0) { value = null; }
5
+ if (parent === void 0) { parent = null; }
6
+ this.id = id;
7
+ this.value = value;
8
+ this.parent = parent;
9
+ this.children = [];
10
+ }
11
+ Object.defineProperty(TreeNode.prototype, "hasChildren", {
12
+ get: function () {
13
+ return this.children.length !== 0;
14
+ },
15
+ enumerable: false,
16
+ configurable: true
17
+ });
18
+ return TreeNode;
19
+ }());
20
+ export { TreeNode };
21
+ var Tree = /** @class */ (function () {
22
+ function Tree(id, value) {
23
+ if (value === void 0) { value = null; }
24
+ this.root = new TreeNode(id, value);
25
+ }
26
+ Tree.prototype.preOrderTraversal = function (node) {
27
+ var _a, _b, child, e_1_1;
28
+ var e_1, _c;
29
+ if (node === void 0) { node = this.root; }
30
+ return __generator(this, function (_d) {
31
+ switch (_d.label) {
32
+ case 0: return [4 /*yield*/, node];
33
+ case 1:
34
+ _d.sent();
35
+ if (!node.children.length) return [3 /*break*/, 9];
36
+ _d.label = 2;
37
+ case 2:
38
+ _d.trys.push([2, 7, 8, 9]);
39
+ _a = __values(node.children), _b = _a.next();
40
+ _d.label = 3;
41
+ case 3:
42
+ if (!!_b.done) return [3 /*break*/, 6];
43
+ child = _b.value;
44
+ return [5 /*yield**/, __values(this.preOrderTraversal(child))];
45
+ case 4:
46
+ _d.sent();
47
+ _d.label = 5;
48
+ case 5:
49
+ _b = _a.next();
50
+ return [3 /*break*/, 3];
51
+ case 6: return [3 /*break*/, 9];
52
+ case 7:
53
+ e_1_1 = _d.sent();
54
+ e_1 = { error: e_1_1 };
55
+ return [3 /*break*/, 9];
56
+ case 8:
57
+ try {
58
+ if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
59
+ }
60
+ finally { if (e_1) throw e_1.error; }
61
+ return [7 /*endfinally*/];
62
+ case 9: return [2 /*return*/];
63
+ }
64
+ });
65
+ };
66
+ Tree.prototype.insert = function (parentId, id, value) {
67
+ var e_2, _a;
68
+ if (value === void 0) { value = null; }
69
+ if (!id) {
70
+ return false;
71
+ }
72
+ try {
73
+ for (var _b = __values(this.preOrderTraversal()), _c = _b.next(); !_c.done; _c = _b.next()) {
74
+ var node = _c.value;
75
+ if (node.id === parentId && node.children.every(function (node) { return node.id !== id; })) {
76
+ node.children.push(new TreeNode(id, value, node));
77
+ return true;
78
+ }
79
+ }
80
+ }
81
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
82
+ finally {
83
+ try {
84
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
85
+ }
86
+ finally { if (e_2) throw e_2.error; }
87
+ }
88
+ return false;
89
+ };
90
+ Tree.prototype.remove = function (id) {
91
+ var e_3, _a;
92
+ try {
93
+ for (var _b = __values(this.preOrderTraversal()), _c = _b.next(); !_c.done; _c = _b.next()) {
94
+ var node = _c.value;
95
+ var filtered = node.children.filter(function (c) { return c.id !== id; });
96
+ if (filtered.length !== node.children.length) {
97
+ node.children = filtered;
98
+ return true;
99
+ }
100
+ }
101
+ }
102
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
103
+ finally {
104
+ try {
105
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
106
+ }
107
+ finally { if (e_3) throw e_3.error; }
108
+ }
109
+ return false;
110
+ };
111
+ Tree.prototype.find = function (id) {
112
+ var e_4, _a;
113
+ if (!id) {
114
+ return undefined;
115
+ }
116
+ try {
117
+ for (var _b = __values(this.preOrderTraversal()), _c = _b.next(); !_c.done; _c = _b.next()) {
118
+ var node = _c.value;
119
+ if (node.id === id) {
120
+ return node;
121
+ }
122
+ }
123
+ }
124
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
125
+ finally {
126
+ try {
127
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
128
+ }
129
+ finally { if (e_4) throw e_4.error; }
130
+ }
131
+ return undefined;
132
+ };
133
+ return Tree;
134
+ }());
135
+ export { Tree };
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { CommonClickableElementProps } from './ClickableElement.js';
3
- export type BackButtonProps = Pick<CommonClickableElementProps, 'caption' | 'id'>;
3
+ export interface BackButtonProps extends Pick<CommonClickableElementProps, 'caption' | 'id'> {
4
+ href?: string;
5
+ }
4
6
  declare const BackButtonWithStaticFields: React.ForwardRefExoticComponent<BackButtonProps & React.RefAttributes<HTMLButtonElement>> & {
5
7
  __KONTUR_REACT_UI__: string;
6
8
  };
@@ -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 '../navigationAttributes.js';
4
+ import { navigationAttributeBackButton } from '../Navigation.js';
5
5
  import { SideMenuContext } from '../SideMenuContext.js';
6
6
  import { SideMenuItem } from '../SideMenuItem/SideMenuItem.js';
7
7
  /**
@@ -14,9 +14,8 @@ 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
- if (id !== undefined) {
18
- context.dispatch({ type: 'SELECT', id: id, isButton: false });
19
- }
17
+ var _a;
18
+ (_a = context.navigation) === null || _a === void 0 ? void 0 : _a.switchActiveMenuItem(id);
20
19
  };
21
20
  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)));
22
21
  });
@@ -19,13 +19,6 @@ export interface CommonClickableElementProps extends CommonProps {
19
19
  disabled?: boolean;
20
20
  /** Отключает перенос строки у заголовка элемента, вместо этого он будет обрезаться многоточием. */
21
21
  noWrap?: boolean;
22
- /**
23
- * Текст всплывающей подсказки (`Hint`) над элементом. Показывается только в свёрнутом
24
- * меню (наведение мыши); в развёрнутом — подавляется, т.к. подпись и так видна.
25
- * Для доступности в свёрнутом состоянии передавайте также `aria-label` — `hint` носит
26
- * визуальный характер и не подставляется в `aria-label` автоматически.
27
- */
28
- hint?: ReactNode;
29
22
  /** @ignore */
30
23
  _isSubMenu?: boolean;
31
24
  /** @ignore */
@@ -44,7 +37,7 @@ export interface ClickableElementProps extends CommonClickableElementProps {
44
37
  onFocus?: React.EventHandler<React.FocusEvent>;
45
38
  onBlur?: React.EventHandler<React.FocusEvent>;
46
39
  }
47
- declare const ClickableElementWithStaticFields: React.ForwardRefExoticComponent<ClickableElementProps & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>> & {
40
+ declare const ClickableElementWithStaticFields: React.ForwardRefExoticComponent<ClickableElementProps & React.RefAttributes<HTMLAnchorElement | HTMLButtonElement>> & {
48
41
  __KONTUR_REACT_UI__: string;
49
42
  };
50
43
  export { ClickableElementWithStaticFields as ClickableElement };