@skbkontur/side-menu 1.12.9 → 2.0.2
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 +32 -0
- package/README.md +61 -195
- package/SideMenuDataTids.d.ts +1 -0
- package/SideMenuDataTids.js +1 -0
- package/hooks/useAnimateOnMount.js +3 -2
- package/lib/theming/ThemeHelpers.js +14 -3
- package/lib/utils/scripts.d.ts +2 -10
- package/lib/utils/scripts.js +3 -75
- package/package.json +2 -2
- package/src/Navigation.d.ts +50 -0
- package/src/Navigation.js +150 -0
- package/src/SideMenu/SideMenu.d.ts +8 -0
- package/src/SideMenu/SideMenu.js +53 -34
- package/src/SideMenu/SideMenu.styles.d.ts +1 -0
- package/src/SideMenu/SideMenu.styles.js +5 -2
- package/src/SideMenuBody/SideMenuBody.js +7 -9
- package/src/SideMenuContext.d.ts +2 -9
- package/src/SideMenuDropdown/SideMenuDropdown.d.ts +1 -3
- package/src/SideMenuDropdown/SideMenuDropdown.js +1 -1
- package/src/SideMenuFooter/SideMenuFooter.js +3 -11
- package/src/SideMenuHeader/SideMenuHeader.js +3 -2
- package/src/SideMenuSubItem/SideMenuSubItem.js +3 -16
- package/src/SideMenuSubLink/SideMenuSubLink.js +4 -17
- package/src/Tree.d.ts +17 -0
- package/src/Tree.js +133 -0
- package/src/internal/BackButton.d.ts +0 -1
- package/src/internal/BackButton.js +3 -15
- package/src/internal/ClickableElement.d.ts +1 -5
- package/src/internal/ClickableElement.js +48 -45
- package/src/internal/InnerSubMenu.d.ts +1 -1
- package/src/internal/InnerSubMenu.js +10 -19
- package/src/internal/ItemContent/Caption.d.ts +2 -1
- package/src/internal/ItemContent/Caption.js +6 -5
- package/src/internal/ItemContent/ItemContent.d.ts +3 -1
- package/src/internal/ItemContent/ItemContent.js +6 -4
- package/src/internal/NestedMenu.d.ts +2 -2
- package/src/internal/NestedMenu.js +6 -16
- package/src/internal/SeparatedSubMenu.d.ts +2 -3
- package/src/internal/SeparatedSubMenu.js +17 -43
- package/src/internal/SideMenuLogotype.js +3 -3
- package/src/internal/SubMenu.d.ts +1 -4
- package/src/internal/SubMenu.js +8 -10
- package/hooks/useActiveState.d.ts +0 -1
- package/hooks/useActiveState.js +0 -12
- package/hooks/useOpenedState.d.ts +0 -2
- package/hooks/useOpenedState.js +0 -14
- package/hooks/useOpenedSubElementState.d.ts +0 -1
- package/hooks/useOpenedSubElementState.js +0 -12
- package/src/internal/InnerBody.d.ts +0 -14
- package/src/internal/InnerBody.js +0 -108
|
@@ -6,21 +6,21 @@ import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
|
|
|
6
6
|
import { jsStylesForSideMenu } from '../SideMenu/SideMenu.styles';
|
|
7
7
|
import { customStyles, jsStyles } from './SeparatedSubMenu.styles';
|
|
8
8
|
import { SideMenuContext } from '../SideMenuContext';
|
|
9
|
-
import { isClickableSubElement } from '../../lib/utils/scripts';
|
|
10
9
|
import { BackButton } from './BackButton';
|
|
11
10
|
import { SideMenuDataTids } from '../../SideMenuDataTids';
|
|
12
11
|
import { ScrollContainer } from '@skbkontur/react-ui';
|
|
13
12
|
import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers';
|
|
14
13
|
import { isIE11 } from '@skbkontur/react-ui/lib/client';
|
|
14
|
+
import { navigationAttributeForSeparatedMenu } from '../Navigation';
|
|
15
15
|
/**
|
|
16
16
|
* Отдельностоящее подменю
|
|
17
17
|
*
|
|
18
18
|
* @visibleName SeparatedSubMenu
|
|
19
19
|
*/
|
|
20
20
|
var SeparatedSubMenu = forwardRef(function (_a, ref) {
|
|
21
|
-
var _b, _c;
|
|
22
|
-
var
|
|
23
|
-
var children = _a.children,
|
|
21
|
+
var _b, _c, _d;
|
|
22
|
+
var _e, _f, _g;
|
|
23
|
+
var children = _a.children, caption = _a.caption, htmlId = _a.htmlId, isOpened = _a.isOpened;
|
|
24
24
|
var context = useContext(SideMenuContext);
|
|
25
25
|
var scrollContainerRef = useRef(null);
|
|
26
26
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
@@ -30,27 +30,13 @@ var SeparatedSubMenu = forwardRef(function (_a, ref) {
|
|
|
30
30
|
}
|
|
31
31
|
setTimeout(function () {
|
|
32
32
|
var _a, _b;
|
|
33
|
-
|
|
34
|
-
(_a = context.setHasScrollBar) === null || _a === void 0 ? void 0 : _a.call(context, (_b = scrollContainerRef.current) === null || _b === void 0 ? void 0 : _b.hasScrollBar('y'));
|
|
33
|
+
isOpened && ((_a = context.setHasScrollBar) === null || _a === void 0 ? void 0 : _a.call(context, !!((_b = scrollContainerRef.current) === null || _b === void 0 ? void 0 : _b.hasScrollBar('y'))));
|
|
35
34
|
}, 50);
|
|
36
|
-
}, [context.activeMenuItem]);
|
|
37
|
-
|
|
38
|
-
// @ts-expect-error: accessing private property
|
|
39
|
-
return isClickableSubElement(child.type.__KONTUR_REACT_UI__) && child.props.children;
|
|
40
|
-
};
|
|
41
|
-
var hasSubItems = function (children) {
|
|
42
|
-
return React.Children.toArray(children).some(function (child) {
|
|
43
|
-
if (React.isValidElement(child)) {
|
|
44
|
-
return isSubItemWithChildren(child);
|
|
45
|
-
}
|
|
46
|
-
return child;
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
var levelIndex = 0;
|
|
50
|
-
if (!((_d = context.sideMenuRef) === null || _d === void 0 ? void 0 : _d.current)) {
|
|
35
|
+
}, [(_e = context.navigation) === null || _e === void 0 ? void 0 : _e.activeMenuItem]);
|
|
36
|
+
if (!((_f = context.sideMenuRef) === null || _f === void 0 ? void 0 : _f.current)) {
|
|
51
37
|
return null;
|
|
52
38
|
}
|
|
53
|
-
return ReactDOM.createPortal(React.createElement("div", { className: cx((_b = {},
|
|
39
|
+
return ReactDOM.createPortal(React.createElement("div", __assign({ className: cx((_b = {},
|
|
54
40
|
_b[jsStylesForSideMenu.container(theme)] = true,
|
|
55
41
|
_b[jsStylesForSideMenu.containerForTouchScreens(theme)] = context.isTouchScreen,
|
|
56
42
|
_b[jsStyles.root(theme)] = true,
|
|
@@ -59,31 +45,19 @@ var SeparatedSubMenu = forwardRef(function (_a, ref) {
|
|
|
59
45
|
_b[jsStyles.rootForTouchScreens(theme)] = context.isTouchScreen && context.isOpened && context.isCollapsable,
|
|
60
46
|
_b[jsStyles.rootForNarrowDesktop(theme)] = context.isCollapsable,
|
|
61
47
|
_b[jsStyles.rootWithShadow(theme)] = context.isTablet && !isIE11,
|
|
62
|
-
_b)
|
|
48
|
+
_b[jsStylesForSideMenu.hidden()] = !isOpened || (!context.isOpened && (context.isTablet || context.isMobile)),
|
|
49
|
+
_b)), ref: ref, "data-tid": SideMenuDataTids.separatedSubMenu }, (_c = {}, _c[navigationAttributeForSeparatedMenu] = htmlId, _c)),
|
|
63
50
|
React.createElement(ScrollContainer, { onScrollStateChangeY: function (state) {
|
|
64
51
|
var _a;
|
|
65
52
|
(_a = context.setScrollState) === null || _a === void 0 ? void 0 : _a.call(context, state);
|
|
66
53
|
}, ref: scrollContainerRef, showScrollBar: context.isTouchScreen ? 'always' : context.showScrollBar, hideScrollBar: context.hideScrollBar },
|
|
67
|
-
React.createElement("ul", { className: cx((
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
context.isMobile && React.createElement(BackButton, { caption: caption, id:
|
|
73
|
-
|
|
74
|
-
if (React.isValidElement(child)) {
|
|
75
|
-
if (
|
|
76
|
-
// @ts-expect-error: accessing private property
|
|
77
|
-
isClickableSubElement(child.type.__KONTUR_REACT_UI__)) {
|
|
78
|
-
var oldIndex = levelIndex;
|
|
79
|
-
levelIndex++;
|
|
80
|
-
return React.cloneElement(child, {
|
|
81
|
-
_generatedId: generatedId + "-" + oldIndex,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
return child;
|
|
85
|
-
}
|
|
86
|
-
}))))), (_e = context.sideMenuRef) === null || _e === void 0 ? void 0 : _e.current);
|
|
54
|
+
React.createElement("ul", { className: cx((_d = {},
|
|
55
|
+
_d[jsStylesForSideMenu.list()] = true,
|
|
56
|
+
_d[jsStyles.contentWrapper(theme)] = true,
|
|
57
|
+
_d[jsStyles.contentWrapperForMobiles()] = context.isMobile,
|
|
58
|
+
_d)) },
|
|
59
|
+
context.isMobile && React.createElement(BackButton, { caption: caption, id: htmlId }),
|
|
60
|
+
children))), (_g = context.sideMenuRef) === null || _g === void 0 ? void 0 : _g.current);
|
|
87
61
|
});
|
|
88
62
|
SeparatedSubMenu.displayName = 'SeparatedSubMenu';
|
|
89
63
|
var SeparatedSubMenuWithStaticFields = Object.assign(SeparatedSubMenu, { __KONTUR_REACT_UI__: 'SeparatedSubMenu' });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __assign, __rest } from "tslib";
|
|
1
|
+
import { __assign, __read, __rest } from "tslib";
|
|
2
2
|
import React, { forwardRef, useContext, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { Logotype } from '@skbkontur/react-ui-addons/components/Logotype';
|
|
4
4
|
import { jsStyles, sideMenuLogotypeIconSize } from './SideMenuLogotype.styles';
|
|
@@ -37,8 +37,8 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
|
|
|
37
37
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
38
38
|
var productName = getProductName(productLogo);
|
|
39
39
|
var refLogotype = useRef(null);
|
|
40
|
-
var _e = useState(28), size = _e[0], setSize = _e[1];
|
|
41
|
-
var _f = useState(getStaticIconPath(productName)), productIconUrl = _f[0], setProductIconUrl = _f[1];
|
|
40
|
+
var _e = __read(useState(28), 2), size = _e[0], setSize = _e[1];
|
|
41
|
+
var _f = __read(useState(getStaticIconPath(productName)), 2), productIconUrl = _f[0], setProductIconUrl = _f[1];
|
|
42
42
|
useEffect(function () {
|
|
43
43
|
var _a, _b;
|
|
44
44
|
var logotypeWidth = (_b = (_a = refLogotype.current) === null || _a === void 0 ? void 0 : _a.logotypeRef) === null || _b === void 0 ? void 0 : _b.clientWidth;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CommonClickableElementProps } from './ClickableElement';
|
|
3
|
-
interface SubMenuProps extends Pick<CommonClickableElementProps, 'caption'
|
|
3
|
+
interface SubMenuProps extends Pick<CommonClickableElementProps, 'caption'> {
|
|
4
4
|
children?: React.ReactNode;
|
|
5
|
-
generatedId?: string;
|
|
6
5
|
isOpened?: boolean;
|
|
7
6
|
isSubMenu?: boolean;
|
|
8
|
-
isMinimized?: boolean;
|
|
9
7
|
isSeparatedMenu?: boolean;
|
|
10
|
-
href?: string;
|
|
11
8
|
htmlId: string;
|
|
12
9
|
}
|
|
13
10
|
declare const SubMenuWithStaticFields: React.ForwardRefExoticComponent<SubMenuProps & React.RefAttributes<HTMLDivElement | HTMLUListElement>> & {
|
package/src/internal/SubMenu.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef, useContext } from 'react';
|
|
2
2
|
import { SeparatedSubMenu } from './SeparatedSubMenu';
|
|
3
3
|
import { InnerSubMenu } from './InnerSubMenu';
|
|
4
|
+
import { NestedMenu } from './NestedMenu';
|
|
4
5
|
import { SideMenuContext } from '../SideMenuContext';
|
|
5
6
|
/**
|
|
6
7
|
* Подменю
|
|
@@ -8,19 +9,16 @@ import { SideMenuContext } from '../SideMenuContext';
|
|
|
8
9
|
* @visibleName InnerSubMenu
|
|
9
10
|
*/
|
|
10
11
|
var SubMenu = forwardRef(function (_a, ref) {
|
|
11
|
-
var
|
|
12
|
+
var _b;
|
|
13
|
+
var children = _a.children, isOpened = _a.isOpened, isSubMenu = _a.isSubMenu, isSeparatedMenu = _a.isSeparatedMenu, caption = _a.caption, htmlId = _a.htmlId;
|
|
12
14
|
var context = useContext(SideMenuContext);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return null;
|
|
15
|
+
if (isSubMenu) {
|
|
16
|
+
return (React.createElement(NestedMenu, { ref: ref, htmlId: htmlId, isOpened: isOpened }, children));
|
|
16
17
|
}
|
|
17
|
-
if (isSeparatedMenu
|
|
18
|
-
(
|
|
19
|
-
(context.isOpened && (context.isMobile || context.isTablet)) ||
|
|
20
|
-
context.isBeingTransitioned)) {
|
|
21
|
-
return (React.createElement(SeparatedSubMenu, { generatedId: generatedId, id: id, href: href, ref: ref, caption: caption, htmlId: htmlId }, children));
|
|
18
|
+
if (isSeparatedMenu) {
|
|
19
|
+
return (React.createElement(SeparatedSubMenu, { ref: ref, caption: caption, htmlId: htmlId, isOpened: isOpened && ((_b = context.navigation) === null || _b === void 0 ? void 0 : _b.isSeparatedMenuShown) }, children));
|
|
22
20
|
}
|
|
23
|
-
return (React.createElement(InnerSubMenu, {
|
|
21
|
+
return (React.createElement(InnerSubMenu, { ref: ref, htmlId: htmlId, isOpened: isOpened }, children));
|
|
24
22
|
});
|
|
25
23
|
SubMenu.displayName = 'SubMenu';
|
|
26
24
|
var SubMenuWithStaticFields = Object.assign(SubMenu, { __KONTUR_REACT_UI__: 'SubMenu' });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useActiveState: (id?: string | undefined, href?: string | undefined, generatedId?: string | undefined, activeMenuItem?: string | null | undefined) => boolean;
|
package/hooks/useActiveState.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
import { isElementActive } from '../lib/utils/scripts';
|
|
3
|
-
export var useActiveState = function (id, href, generatedId, activeMenuItem) {
|
|
4
|
-
var _a = useState(false), isActive = _a[0], setIsActive = _a[1];
|
|
5
|
-
useEffect(function () {
|
|
6
|
-
var isHrefActive = isElementActive(href, activeMenuItem);
|
|
7
|
-
var isIdActive = isElementActive(id, activeMenuItem);
|
|
8
|
-
var isGeneratedIdActive = isElementActive(generatedId, activeMenuItem);
|
|
9
|
-
setIsActive(isHrefActive || isIdActive || isGeneratedIdActive);
|
|
10
|
-
}, [activeMenuItem]);
|
|
11
|
-
return isActive;
|
|
12
|
-
};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export declare const useOpenedState: (id?: string | undefined, generatedId?: string | undefined, openedParents?: string[] | undefined, isActive?: boolean, children?: React.ReactNode, separatedMenuIsShown?: boolean | undefined, isMobileAndSeparatedMenu?: boolean | undefined) => boolean;
|
package/hooks/useOpenedState.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
import { isParentOpened } from '../lib/utils/scripts';
|
|
3
|
-
export var useOpenedState = function (id, generatedId, openedParents, isActive, children, separatedMenuIsShown, isMobileAndSeparatedMenu) {
|
|
4
|
-
if (isActive === void 0) { isActive = false; }
|
|
5
|
-
var _a = useState(false), isOpened = _a[0], setIsOpened = _a[1];
|
|
6
|
-
useEffect(function () {
|
|
7
|
-
var isOpenedParent = isParentOpened(id, generatedId, openedParents);
|
|
8
|
-
var isOpenedOrActiveClickableElement = !!children && (isOpenedParent || isActive);
|
|
9
|
-
var isOpenedInOpenedSeparatedMenu = isOpenedOrActiveClickableElement && !!separatedMenuIsShown;
|
|
10
|
-
var isOpened = isMobileAndSeparatedMenu ? isOpenedInOpenedSeparatedMenu : isOpenedOrActiveClickableElement;
|
|
11
|
-
setIsOpened(isOpened);
|
|
12
|
-
}, [openedParents === null || openedParents === void 0 ? void 0 : openedParents.toString(), isActive, separatedMenuIsShown]);
|
|
13
|
-
return isOpened;
|
|
14
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useOpenedSubElementState: (id?: string | undefined, generatedId?: string | undefined, openedParents?: string[] | undefined, activeMenuItem?: string | null | undefined) => boolean;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
import { isElementActive, isParentOpened } from '../lib/utils/scripts';
|
|
3
|
-
export var useOpenedSubElementState = function (id, generatedId, openedParents, activeMenuItem) {
|
|
4
|
-
var _a = useState(false), isOpened = _a[0], setIsOpened = _a[1];
|
|
5
|
-
useEffect(function () {
|
|
6
|
-
var isOpenedParent = isParentOpened(id, generatedId, openedParents);
|
|
7
|
-
var isIdActive = isElementActive(id, activeMenuItem);
|
|
8
|
-
var isGeneratedIdActive = isElementActive(generatedId, activeMenuItem);
|
|
9
|
-
setIsOpened(isOpenedParent || isOpened || isIdActive || isGeneratedIdActive);
|
|
10
|
-
}, [openedParents === null || openedParents === void 0 ? void 0 : openedParents.toString(), activeMenuItem]);
|
|
11
|
-
return isOpened;
|
|
12
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { CommonProps } from '@skbkontur/react-ui/internal/CommonWrapper';
|
|
3
|
-
export interface FlattedArrayElementType {
|
|
4
|
-
id: string;
|
|
5
|
-
generatedId: string;
|
|
6
|
-
parentId: string | null;
|
|
7
|
-
generatedParentId: string | null;
|
|
8
|
-
childrenId: string[];
|
|
9
|
-
generatedChildrenId: string[];
|
|
10
|
-
}
|
|
11
|
-
declare const InnerBodyWithStaticFields: React.FC<CommonProps> & {
|
|
12
|
-
__KONTUR_REACT_UI__: string;
|
|
13
|
-
};
|
|
14
|
-
export { InnerBodyWithStaticFields as InnerBody };
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { __assign, __spreadArrays } from "tslib";
|
|
2
|
-
import React, { isValidElement, useContext, useEffect, useRef, useState } from 'react';
|
|
3
|
-
import { SideMenuContext } from '../SideMenuContext';
|
|
4
|
-
import { getAllParents, getChildrenIdArray, getElementsChildren, getItemId, isClickableElement, } from '../../lib/utils/scripts';
|
|
5
|
-
/**
|
|
6
|
-
* Внутренняя часть SideMenuBody
|
|
7
|
-
*
|
|
8
|
-
* @visibleName InnerBody
|
|
9
|
-
*/
|
|
10
|
-
var InnerBody = function (_a) {
|
|
11
|
-
var children = _a.children;
|
|
12
|
-
var context = useContext(SideMenuContext);
|
|
13
|
-
var _b = useState([]), parents = _b[0], setParents = _b[1];
|
|
14
|
-
var flattedArrayOfAllElements = useRef([]);
|
|
15
|
-
var getFlattedArrayOfAllElements = function () {
|
|
16
|
-
var levelIndex = 0;
|
|
17
|
-
React.Children.map(children, function (child) {
|
|
18
|
-
if (isValidElement(child) &&
|
|
19
|
-
// @ts-expect-error: accessing private property
|
|
20
|
-
isClickableElement(child.type.__KONTUR_REACT_UI__)) {
|
|
21
|
-
var generatedId = getItemId('body', levelIndex++);
|
|
22
|
-
var childrenArray = getElementsChildren(child, generatedId);
|
|
23
|
-
var childrenId = getChildrenIdArray(childrenArray, child.props.id);
|
|
24
|
-
var generatedChildrenId = getChildrenIdArray(childrenArray, generatedId, true);
|
|
25
|
-
flattedArrayOfAllElements.current.push({
|
|
26
|
-
id: child.props.id || child.props.href,
|
|
27
|
-
generatedId: generatedId,
|
|
28
|
-
parentId: null,
|
|
29
|
-
generatedParentId: null,
|
|
30
|
-
childrenId: childrenId,
|
|
31
|
-
generatedChildrenId: generatedChildrenId,
|
|
32
|
-
});
|
|
33
|
-
childrenArray.forEach(function (el) { return flattedArrayOfAllElements.current.push(el); });
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
var getActiveItems = function (activeItem) {
|
|
38
|
-
if (activeItem) {
|
|
39
|
-
return getAllParents(activeItem, flattedArrayOfAllElements.current);
|
|
40
|
-
}
|
|
41
|
-
return [];
|
|
42
|
-
};
|
|
43
|
-
var getOpenedParents = function () {
|
|
44
|
-
var activeMenuItems = getActiveItems(context.activeMenuItem);
|
|
45
|
-
var clickedButtons = getActiveItems(context.clickedButton);
|
|
46
|
-
setParents(__spreadArrays(activeMenuItems, clickedButtons));
|
|
47
|
-
};
|
|
48
|
-
var activeMenuItemHasParent = function () {
|
|
49
|
-
if (!context.activeMenuItem)
|
|
50
|
-
return;
|
|
51
|
-
var parentOfActiveMenuItem = getAllParents(context.activeMenuItem, flattedArrayOfAllElements.current);
|
|
52
|
-
return parentOfActiveMenuItem.length > 0;
|
|
53
|
-
};
|
|
54
|
-
var activeMenuItemHasChildren = function () {
|
|
55
|
-
if (!context.activeMenuItem)
|
|
56
|
-
return;
|
|
57
|
-
var childrenOfActiveMenuItem = getChildrenIdArray(flattedArrayOfAllElements.current, context.activeMenuItem);
|
|
58
|
-
var childrenOfActiveMenuItemGenerated = getChildrenIdArray(flattedArrayOfAllElements.current, context.activeMenuItem, true);
|
|
59
|
-
return childrenOfActiveMenuItem.length > 0 || childrenOfActiveMenuItemGenerated.length > 0;
|
|
60
|
-
};
|
|
61
|
-
var setSeparatedMenuIsShown = function () {
|
|
62
|
-
var _a, _b;
|
|
63
|
-
if (!context.isSeparatedMenu)
|
|
64
|
-
return;
|
|
65
|
-
var activeItemHasParent = activeMenuItemHasParent();
|
|
66
|
-
var isActive = activeItemHasParent || activeMenuItemHasChildren() || false;
|
|
67
|
-
var isMinimizedInWideDesktop = !context.isOpened && context.isDesktop && !context.isCollapsable;
|
|
68
|
-
if (context.isMobile && !activeItemHasParent && context.isSeparatedMenuShown) {
|
|
69
|
-
return (_a = context.setIsSeparatedMenuShown) === null || _a === void 0 ? void 0 : _a.call(context, false);
|
|
70
|
-
}
|
|
71
|
-
(_b = context.setIsSeparatedMenuShown) === null || _b === void 0 ? void 0 : _b.call(context, isActive && !isMinimizedInWideDesktop);
|
|
72
|
-
};
|
|
73
|
-
useEffect(function () {
|
|
74
|
-
getFlattedArrayOfAllElements();
|
|
75
|
-
}, [children]);
|
|
76
|
-
useEffect(function () {
|
|
77
|
-
getOpenedParents();
|
|
78
|
-
setSeparatedMenuIsShown();
|
|
79
|
-
}, [context.activeMenuItem, context.isOpened, context.clickedButton]);
|
|
80
|
-
useEffect(function () {
|
|
81
|
-
var _a;
|
|
82
|
-
if (context.activeMenuItem && context.clickedButton) {
|
|
83
|
-
if (!getAllParents(context.activeMenuItem, flattedArrayOfAllElements.current).includes(context.clickedButton)) {
|
|
84
|
-
(_a = context.setClickedButton) === null || _a === void 0 ? void 0 : _a.call(context, null);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}, [context.activeMenuItem]);
|
|
88
|
-
var levelIndex = 0;
|
|
89
|
-
return (React.createElement(SideMenuContext.Provider, { value: __assign({ openedParents: parents, flattedArrayOfAllElements: flattedArrayOfAllElements.current }, context) }, React.Children.map(children, function (child) {
|
|
90
|
-
if (React.isValidElement(child)) {
|
|
91
|
-
if (
|
|
92
|
-
// @ts-expect-error: accessing private property
|
|
93
|
-
isClickableElement(child.type.__KONTUR_REACT_UI__)) {
|
|
94
|
-
var oldIndex = levelIndex;
|
|
95
|
-
levelIndex++;
|
|
96
|
-
return React.cloneElement(child, {
|
|
97
|
-
_generatedId: getItemId('body', oldIndex),
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
return child;
|
|
101
|
-
}
|
|
102
|
-
})));
|
|
103
|
-
};
|
|
104
|
-
InnerBody.displayName = 'InnerBody';
|
|
105
|
-
var InnerBodyWithStaticFields = Object.assign(InnerBody, {
|
|
106
|
-
__KONTUR_REACT_UI__: 'InnerBody',
|
|
107
|
-
});
|
|
108
|
-
export { InnerBodyWithStaticFields as InnerBody };
|