@skbkontur/side-menu 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +2 -2
- package/SideMenuDataTids.d.ts +6 -0
- package/SideMenuDataTids.js +6 -0
- package/hooks/{UseMemoIcon.d.ts → useMemoIcon.d.ts} +0 -0
- package/hooks/{UseMemoIcon.js → useMemoIcon.js} +0 -0
- package/hooks/useMobileSeparatedMenuScroll.d.ts +1 -0
- package/hooks/useMobileSeparatedMenuScroll.js +21 -0
- package/hooks/useOpenedState.d.ts +1 -1
- package/hooks/useOpenedState.js +6 -3
- package/hooks/useOpenedSubElementState.js +1 -1
- package/package.json +1 -1
- package/src/SideMenu/SideMenu.d.ts +1 -4
- package/src/SideMenu/SideMenu.js +47 -40
- package/src/SideMenu/SideMenu.styles.d.ts +5 -3
- package/src/SideMenu/SideMenu.styles.js +17 -11
- package/src/SideMenuContext.d.ts +4 -0
- package/src/SideMenuDropdown/SideMenuDropdown.d.ts +2 -0
- package/src/SideMenuHeader/SideMenuHeader.js +12 -6
- package/src/SideMenuHeader/SideMenuHeader.styles.d.ts +2 -1
- package/src/SideMenuHeader/SideMenuHeader.styles.js +8 -4
- package/src/SideMenuSubItem/SideMenuSubItem.js +1 -1
- package/src/SideMenuSubLink/SideMenuSubLink.js +1 -1
- package/src/internal/BackButton.d.ts +11 -0
- package/src/internal/BackButton.js +30 -0
- package/src/internal/Backdrop.js +5 -2
- package/src/internal/Backdrop.styles.d.ts +1 -1
- package/src/internal/Backdrop.styles.js +1 -1
- package/src/internal/Burger.js +2 -2
- package/src/internal/Burger.styles.d.ts +1 -1
- package/src/internal/Burger.styles.js +1 -1
- package/src/internal/ClickableElement.d.ts +7 -0
- package/src/internal/ClickableElement.js +8 -5
- package/src/internal/ItemContent/Caption.d.ts +2 -3
- package/src/internal/ItemContent/Caption.js +5 -3
- package/src/internal/ItemContent/Caption.styles.d.ts +1 -0
- package/src/internal/ItemContent/Caption.styles.js +4 -1
- package/src/internal/ItemContent/Icon.d.ts +3 -4
- package/src/internal/ItemContent/Icon.js +10 -4
- package/src/internal/ItemContent/Icon.styles.d.ts +1 -0
- package/src/internal/ItemContent/Icon.styles.js +4 -1
- package/src/internal/ItemContent/ItemContent.d.ts +1 -2
- package/src/internal/ItemContent/ItemContent.js +4 -4
- package/src/internal/ItemContent/Marker.d.ts +2 -2
- package/src/internal/SeparatedSubMenu.d.ts +3 -0
- package/src/internal/SeparatedSubMenu.js +9 -2
- package/src/internal/SeparatedSubMenu.styles.d.ts +1 -0
- package/src/internal/SeparatedSubMenu.styles.js +5 -1
- package/src/internal/SideMenuLogotype.js +8 -5
- package/src/internal/SubMenu.d.ts +3 -0
- package/src/internal/SubMenu.js +2 -2
- package/utils/scripts.d.ts +1 -0
- package/utils/scripts.js +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.6.0](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@0.5.1...@skbkontur/side-menu@0.6.0) (2023-02-08)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **SideMenu:** implement mobile adaptive version ([9a1e347](https://git.skbkontur.ru/ui/ui-parking/commits/9a1e347519afd0684c30b98a42191ced336b075f))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [0.5.1](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@0.5.0...@skbkontur/side-menu@0.5.1) (2023-01-24)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @skbkontur/side-menu
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
AttachLinkIcon,
|
|
20
20
|
} from '@skbkontur/icons';
|
|
21
21
|
|
|
22
|
-
<div style={{height: '600px'}}>
|
|
22
|
+
<div style={{height: '600px', position: 'relative'}}>
|
|
23
23
|
<SideMenu disableSwipe={false}>
|
|
24
24
|
<SideMenu.Header konturLogo={<Kontur/>} productLogo={<Ofd/>}/>
|
|
25
25
|
<SideMenu.Body>
|
|
@@ -120,7 +120,7 @@ const renderModal = () => {
|
|
|
120
120
|
);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
<div style={{height: '600px', width: '100%'}}>
|
|
123
|
+
<div style={{height: '600px', width: '100%', position: 'relative'}}>
|
|
124
124
|
<SideMenu isSeparatedMenu={true}>
|
|
125
125
|
<SideMenu.Header konturLogo={<Kontur/>} productLogo={<Buhgalteria/>}/>
|
|
126
126
|
<SideMenu.Body>
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useMobileSeparatedMenuScroll: () => import("react").RefObject<HTMLDivElement>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useContext, useEffect, useRef } from 'react';
|
|
2
|
+
import { SideMenuContext } from '../src/SideMenuContext';
|
|
3
|
+
export var useMobileSeparatedMenuScroll = function () {
|
|
4
|
+
var separatedMenuRef = useRef(null);
|
|
5
|
+
var context = useContext(SideMenuContext);
|
|
6
|
+
var checkScroll = function () {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
var isScrolledToTop = ((_a = separatedMenuRef.current) === null || _a === void 0 ? void 0 : _a.scrollTop) === 0;
|
|
9
|
+
(_b = context.setMobileSeparatedMenuIsScrolling) === null || _b === void 0 ? void 0 : _b.call(context, !isScrolledToTop);
|
|
10
|
+
};
|
|
11
|
+
useEffect(function () {
|
|
12
|
+
var _a;
|
|
13
|
+
context.isMobile && ((_a = separatedMenuRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('scroll', checkScroll, true));
|
|
14
|
+
return function () {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
(_a = separatedMenuRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('scroll', checkScroll, true);
|
|
17
|
+
(_b = context.setMobileSeparatedMenuIsScrolling) === null || _b === void 0 ? void 0 : _b.call(context, false);
|
|
18
|
+
};
|
|
19
|
+
}, []);
|
|
20
|
+
return separatedMenuRef;
|
|
21
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare const useOpenedState: (id?: string | undefined, generatedId?: string | undefined, openedParents?: string[] | undefined, isActive?: boolean, children?: React.ReactNode) => boolean;
|
|
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
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
2
|
import { isParentOpened } from '../utils/scripts';
|
|
3
|
-
export var useOpenedState = function (id, generatedId, openedParents, isActive, children) {
|
|
3
|
+
export var useOpenedState = function (id, generatedId, openedParents, isActive, children, separatedMenuIsShown, isMobileAndSeparatedMenu) {
|
|
4
4
|
if (isActive === void 0) { isActive = false; }
|
|
5
5
|
var _a = useState(false), isOpened = _a[0], setIsOpened = _a[1];
|
|
6
6
|
useEffect(function () {
|
|
7
7
|
var isOpenedParent = isParentOpened(id, generatedId, openedParents);
|
|
8
|
-
|
|
9
|
-
|
|
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]);
|
|
10
13
|
return isOpened;
|
|
11
14
|
};
|
|
@@ -7,6 +7,6 @@ export var useOpenedSubElementState = function (id, generatedId, openedParents,
|
|
|
7
7
|
var idIsActive = isIdActive(id, activeMenuItem);
|
|
8
8
|
var generatedIdIsActive = isIdActive(generatedId, activeMenuItem);
|
|
9
9
|
setIsOpened(isOpenedParent || isOpened || idIsActive || generatedIdIsActive);
|
|
10
|
-
}, [openedParents === null || openedParents === void 0 ? void 0 : openedParents.toString()]);
|
|
10
|
+
}, [openedParents === null || openedParents === void 0 ? void 0 : openedParents.toString(), activeMenuItem]);
|
|
11
11
|
return isOpened;
|
|
12
12
|
};
|
package/package.json
CHANGED
|
@@ -20,6 +20,7 @@ export interface SideMenuProps extends CommonProps {
|
|
|
20
20
|
value?: string;
|
|
21
21
|
onValueChange?: (value: string) => void;
|
|
22
22
|
tabletMediaQuery?: string;
|
|
23
|
+
mobileMediaQuery?: string;
|
|
23
24
|
}
|
|
24
25
|
interface SubComponents {
|
|
25
26
|
Body: typeof SideMenuBody;
|
|
@@ -36,9 +37,5 @@ interface SubComponents {
|
|
|
36
37
|
SubLink: typeof SideMenuSubLink;
|
|
37
38
|
__KONTUR_REACT_UI__: string;
|
|
38
39
|
}
|
|
39
|
-
export declare const SideMenuDataTids: {
|
|
40
|
-
root: string;
|
|
41
|
-
burger: string;
|
|
42
|
-
};
|
|
43
40
|
export declare const SideMenu: React.ForwardRefExoticComponent<SideMenuProps & React.RefAttributes<HTMLElement>> & SubComponents;
|
|
44
41
|
export {};
|
package/src/SideMenu/SideMenu.js
CHANGED
|
@@ -19,38 +19,38 @@ import { SideMenuLink } from '../SideMenuLink/SideMenuLink';
|
|
|
19
19
|
import { SideMenuSubLink } from '../SideMenuSubLink/SideMenuSubLink';
|
|
20
20
|
import { useResponsiveLayout } from '@skbkontur/react-ui';
|
|
21
21
|
import { Backdrop } from '../internal/Backdrop';
|
|
22
|
-
import { ZIndex } from '@skbkontur/react-ui/internal/ZIndex';
|
|
23
22
|
import { RenderLayer } from '@skbkontur/react-ui/internal/RenderLayer';
|
|
24
23
|
import { isTouchScreen } from '../../utils/scripts';
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
burger: 'SideMenu__Burger',
|
|
28
|
-
};
|
|
24
|
+
import { SideMenuDataTids } from '../../SideMenuDataTids';
|
|
25
|
+
import { ZIndex } from '@skbkontur/react-ui/internal/ZIndex';
|
|
29
26
|
var SideMenuInner = forwardRef(function (_a, ref) {
|
|
30
27
|
var _b, _c, _d, _e;
|
|
31
|
-
var children = _a.children, value = _a.value, onValueChange = _a.onValueChange, _f = _a.size, size = _f === void 0 ? 'small' : _f, _g = _a.isSeparatedMenu, isSeparatedMenu = _g === void 0 ? false : _g, className = _a.className, _h = _a.disableSwipe, disableSwipe = _h === void 0 ? true : _h, _j = _a.tabletMediaQuery, tabletMediaQuery = _j === void 0 ? '768px' : _j, rest = __rest(_a, ["children", "value", "onValueChange", "size", "isSeparatedMenu", "className", "disableSwipe", "tabletMediaQuery"]);
|
|
28
|
+
var children = _a.children, value = _a.value, onValueChange = _a.onValueChange, _f = _a.size, size = _f === void 0 ? 'small' : _f, _g = _a.isSeparatedMenu, isSeparatedMenu = _g === void 0 ? false : _g, className = _a.className, _h = _a.disableSwipe, disableSwipe = _h === void 0 ? true : _h, _j = _a.tabletMediaQuery, tabletMediaQuery = _j === void 0 ? '768px' : _j, _k = _a.mobileMediaQuery, mobileMediaQuery = _k === void 0 ? '0px' : _k, rest = __rest(_a, ["children", "value", "onValueChange", "size", "isSeparatedMenu", "className", "disableSwipe", "tabletMediaQuery", "mobileMediaQuery"]);
|
|
32
29
|
var scrollTimer = null;
|
|
33
30
|
var transitionTimer = null;
|
|
34
31
|
var widgetTimer;
|
|
35
32
|
var customMediaQueries = {
|
|
36
|
-
isMobile:
|
|
33
|
+
isMobile: "(min-width: " + mobileMediaQuery + ")",
|
|
37
34
|
isTablet: "(min-width: " + tabletMediaQuery + ")",
|
|
38
35
|
isNarrowDesktop: '(min-width: 992px)',
|
|
39
36
|
isDesktop: "(min-width: 1200px)",
|
|
40
37
|
};
|
|
41
|
-
var
|
|
38
|
+
var _l = useResponsiveLayout({
|
|
42
39
|
customMediaQueries: customMediaQueries,
|
|
43
|
-
}), isMobile =
|
|
40
|
+
}), isMobile = _l.isMobile, isTablet = _l.isTablet, isNarrowDesktop = _l.isNarrowDesktop, isDesktop = _l.isDesktop;
|
|
44
41
|
var isTabletSideMenu = isTablet && !isNarrowDesktop;
|
|
45
42
|
var isMobileSideMenu = isMobile && !isTablet;
|
|
43
|
+
var isTabletOrMobileSideMenu = isTabletSideMenu || isMobileSideMenu;
|
|
46
44
|
var isTouchScreenSideMenu = isTouchScreen() || isMobileSideMenu || isTabletSideMenu;
|
|
47
|
-
var
|
|
48
|
-
var
|
|
49
|
-
var
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
var
|
|
53
|
-
var
|
|
45
|
+
var _m = useState(false), isMinimised = _m[0], setIsMinimised = _m[1];
|
|
46
|
+
var _o = useState(false), hasScrollBar = _o[0], setHasScrollBar = _o[1];
|
|
47
|
+
var _p = useState(false), isTransitioned = _p[0], setIsTransitioned = _p[1];
|
|
48
|
+
var _q = useState('#2291ff'), productColor = _q[0], setProductColor = _q[1];
|
|
49
|
+
var _r = useState(false), showWidget = _r[0], setShowWidget = _r[1];
|
|
50
|
+
var _s = useState(value), activeMenuItem = _s[0], setActiveMenuItem = _s[1];
|
|
51
|
+
var _t = useState(isDesktop || isNarrowDesktop), isShown = _t[0], setIsShown = _t[1];
|
|
52
|
+
var _u = useState(false), separatedMenuIsShown = _u[0], setSeparatedMenuIsShown = _u[1];
|
|
53
|
+
var _v = useState(false), mobileSeparatedMenuIsScrolling = _v[0], setMobileSeparatedMenuIsScrolling = _v[1];
|
|
54
54
|
useEffect(function () {
|
|
55
55
|
return function () {
|
|
56
56
|
if (scrollTimer) {
|
|
@@ -106,10 +106,10 @@ var SideMenuInner = forwardRef(function (_a, ref) {
|
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
var toggleIsShown = function () {
|
|
109
|
-
|
|
109
|
+
isTabletOrMobileSideMenu && setIsShown(!isShown);
|
|
110
110
|
};
|
|
111
111
|
var turnOffIsShown = function () {
|
|
112
|
-
|
|
112
|
+
isTabletOrMobileSideMenu && setIsShown(false);
|
|
113
113
|
};
|
|
114
114
|
return (React.createElement(SideMenuContext.Provider, { value: {
|
|
115
115
|
isMinimised: isMinimised,
|
|
@@ -124,34 +124,41 @@ var SideMenuInner = forwardRef(function (_a, ref) {
|
|
|
124
124
|
isDesktop: isDesktop,
|
|
125
125
|
isNarrowDesktop: isNarrowDesktop,
|
|
126
126
|
isTablet: isTabletSideMenu,
|
|
127
|
-
isMobile:
|
|
127
|
+
isMobile: isMobileSideMenu,
|
|
128
128
|
isTouchScreen: isTouchScreenSideMenu,
|
|
129
129
|
isShown: isShown,
|
|
130
130
|
toggleIsShown: toggleIsShown,
|
|
131
|
+
separatedMenuIsShown: separatedMenuIsShown,
|
|
132
|
+
setSeparatedMenuIsShown: setSeparatedMenuIsShown,
|
|
133
|
+
mobileSeparatedMenuIsScrolling: mobileSeparatedMenuIsScrolling,
|
|
134
|
+
setMobileSeparatedMenuIsScrolling: setMobileSeparatedMenuIsScrolling,
|
|
131
135
|
} },
|
|
132
|
-
|
|
133
|
-
React.createElement(ZIndex, { priority: 8000, className: cx((_b = {},
|
|
136
|
+
React.createElement(ZIndex, { priority: isTabletOrMobileSideMenu ? 'Sidepage' : 0, className: cx((_b = {},
|
|
134
137
|
_b[jsStyles.sideMenuZIndex()] = true,
|
|
135
|
-
_b[jsStyles.
|
|
138
|
+
_b[jsStyles.sideMenuZIndexForTabletsOrMobiles()] = isShown && isTabletOrMobileSideMenu,
|
|
136
139
|
_b)) },
|
|
137
|
-
React.createElement(
|
|
138
|
-
React.createElement(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
140
|
+
React.createElement(React.Fragment, null,
|
|
141
|
+
isTabletOrMobileSideMenu && isShown && React.createElement(Backdrop, null),
|
|
142
|
+
React.createElement(RenderLayer, { onClickOutside: turnOffIsShown },
|
|
143
|
+
React.createElement("aside", __assign({ className: cx((_c = {},
|
|
144
|
+
_c[jsStyles.rootWrapper()] = true,
|
|
145
|
+
_c[jsStyles.rootWrapperIE()] = isIE11,
|
|
146
|
+
_c), className), "data-tid": SideMenuDataTids.root, ref: ref }, rest, { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave }),
|
|
147
|
+
React.createElement("div", { className: cx((_d = {},
|
|
148
|
+
_d[jsStyles.root()] = true,
|
|
149
|
+
_d[jsStyles.collapsedRootForTabletsOrMobiles()] = !isShown,
|
|
150
|
+
_d[jsStyles.rootSafari()] = isSafari,
|
|
151
|
+
_d[jsStyles.minimisedRoot()] = isMinimised,
|
|
152
|
+
_d[jsStyles.rootWithInnerSubMenu()] = !isSeparatedMenu,
|
|
153
|
+
_d[jsStyles.rootForTouchScreens()] = isTouchScreenSideMenu,
|
|
154
|
+
_d[jsStyles.rootInSeparatedMenuForMobiles()] = isMobileSideMenu && separatedMenuIsShown && isShown,
|
|
155
|
+
_d)), onMouseOver: showMinimisedRoot, onFocus: showMinimisedRoot, onScroll: handleScroll },
|
|
156
|
+
React.createElement("div", { className: cx((_e = {},
|
|
157
|
+
_e[jsStyles.rootInnerContainer()] = true,
|
|
158
|
+
_e[jsStyles.rootInnerWithoutScrollBar()] = !hasScrollBar,
|
|
159
|
+
_e[jsStyles.collapsedRootInnerForTabletsOrMobiles()] = !isShown || separatedMenuIsShown,
|
|
160
|
+
_e)) }, children)),
|
|
161
|
+
!disableSwipe && isDesktop && React.createElement(RightBorder, { setIsMinimised: setIsMinimised })))))));
|
|
155
162
|
});
|
|
156
163
|
SideMenuInner.displayName = 'SideMenu';
|
|
157
164
|
var STATIC_PROPS = {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
export declare const jsStyles: {
|
|
2
2
|
sideMenuZIndex(): string;
|
|
3
|
-
|
|
3
|
+
sideMenuZIndexForTabletsOrMobiles(): string;
|
|
4
4
|
root(): string;
|
|
5
5
|
rootSafari(): string;
|
|
6
|
-
|
|
6
|
+
rootInnerWithoutScrollBar(): string;
|
|
7
|
+
collapsedRootInnerForTabletsOrMobiles(): string;
|
|
7
8
|
minimisedRoot(): string;
|
|
8
9
|
rootWithInnerSubMenu(): string;
|
|
9
10
|
rootForTouchScreens(): string;
|
|
11
|
+
rootInSeparatedMenuForMobiles(): string;
|
|
10
12
|
rootInnerContainer(): string;
|
|
11
13
|
rootWrapper(): string;
|
|
12
14
|
rootWrapperIE(): string;
|
|
13
|
-
|
|
15
|
+
collapsedRootForTabletsOrMobiles(): string;
|
|
14
16
|
};
|
|
@@ -4,7 +4,7 @@ var styles = {
|
|
|
4
4
|
sideMenuZIndex: function () {
|
|
5
5
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n height: 100%;\n "], ["\n position: relative;\n height: 100%;\n "])));
|
|
6
6
|
},
|
|
7
|
-
|
|
7
|
+
sideMenuZIndexForTabletsOrMobiles: function () {
|
|
8
8
|
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n "], ["\n position: absolute;\n top: 0;\n "])));
|
|
9
9
|
},
|
|
10
10
|
root: function () {
|
|
@@ -13,31 +13,37 @@ var styles = {
|
|
|
13
13
|
rootSafari: function () {
|
|
14
14
|
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n &::-webkit-scrollbar {\n display: block;\n width: 10px;\n }\n &::-webkit-scrollbar-track {\n background: #f1f1f1;\n }\n &::-webkit-scrollbar-thumb {\n background: #888;\n }\n "], ["\n &::-webkit-scrollbar {\n display: block;\n width: 10px;\n }\n &::-webkit-scrollbar-track {\n background: #f1f1f1;\n }\n &::-webkit-scrollbar-thumb {\n background: #888;\n }\n "])));
|
|
15
15
|
},
|
|
16
|
-
|
|
16
|
+
rootInnerWithoutScrollBar: function () {
|
|
17
17
|
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n -ms-overflow-style: none;\n scrollbar-width: none;\n &::-webkit-scrollbar {\n display: none;\n width: 0;\n }\n "], ["\n -ms-overflow-style: none;\n scrollbar-width: none;\n &::-webkit-scrollbar {\n display: none;\n width: 0;\n }\n "])));
|
|
18
18
|
},
|
|
19
|
+
collapsedRootInnerForTabletsOrMobiles: function () {
|
|
20
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n overflow: hidden;\n "], ["\n overflow: hidden;\n "])));
|
|
21
|
+
},
|
|
19
22
|
minimisedRoot: function () {
|
|
20
|
-
return css(
|
|
23
|
+
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n width: 72px !important;\n "], ["\n width: 72px !important;\n "])));
|
|
21
24
|
},
|
|
22
25
|
rootWithInnerSubMenu: function () {
|
|
23
|
-
return css(
|
|
26
|
+
return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n overflow-x: hidden;\n "], ["\n overflow-x: hidden;\n "])));
|
|
24
27
|
},
|
|
25
28
|
rootForTouchScreens: function () {
|
|
26
|
-
return css(
|
|
29
|
+
return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n width: 328px;\n "], ["\n width: 328px;\n "])));
|
|
30
|
+
},
|
|
31
|
+
rootInSeparatedMenuForMobiles: function () {
|
|
32
|
+
return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n background: #fff;\n "], ["\n background: #fff;\n "])));
|
|
27
33
|
},
|
|
28
34
|
rootInnerContainer: function () {
|
|
29
|
-
return css(
|
|
35
|
+
return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n height: calc(100% - 24px);\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n overflow-x: hidden;\n overflow-y: auto;\n padding: 0 16px 24px;\n "], ["\n height: calc(100% - 24px);\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n overflow-x: hidden;\n overflow-y: auto;\n padding: 0 16px 24px;\n "])));
|
|
30
36
|
},
|
|
31
37
|
rootWrapper: function () {
|
|
32
|
-
return css(
|
|
38
|
+
return css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n height: 100%;\n display: inline-flex;\n position: relative;\n "], ["\n height: 100%;\n display: inline-flex;\n position: relative;\n "])));
|
|
33
39
|
},
|
|
34
40
|
rootWrapperIE: function () {
|
|
35
41
|
var ieRootWrapperCorrection = 15;
|
|
36
|
-
return css(
|
|
42
|
+
return css(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n position: relative;\n top: -", "px;\n height: calc(100% + ", "px);\n "], ["\n position: relative;\n top: -", "px;\n height: calc(100% + ", "px);\n "])), ieRootWrapperCorrection, ieRootWrapperCorrection);
|
|
37
43
|
},
|
|
38
|
-
|
|
39
|
-
return css(
|
|
44
|
+
collapsedRootForTabletsOrMobiles: function () {
|
|
45
|
+
return css(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n background-color: transparent;\n "], ["\n background-color: transparent;\n "])));
|
|
40
46
|
},
|
|
41
47
|
};
|
|
42
48
|
export var jsStyles = memoizeStyle(styles);
|
|
43
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12;
|
|
49
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14;
|
package/src/SideMenuContext.d.ts
CHANGED
|
@@ -19,5 +19,9 @@ export interface SideMenuContextType {
|
|
|
19
19
|
isShown?: boolean;
|
|
20
20
|
toggleIsShown?: () => void;
|
|
21
21
|
flattedArrayOfAllElements?: FlattedArrayElementType[];
|
|
22
|
+
separatedMenuIsShown?: boolean;
|
|
23
|
+
setSeparatedMenuIsShown?: (separatedMenuIsShown: boolean) => void;
|
|
24
|
+
mobileSeparatedMenuIsScrolling?: boolean;
|
|
25
|
+
setMobileSeparatedMenuIsScrolling?: (isScrolling: boolean) => void;
|
|
22
26
|
}
|
|
23
27
|
export declare const SideMenuContext: import("react").Context<SideMenuContextType>;
|
|
@@ -6,8 +6,10 @@ export interface SideMenuDropdownProps extends CommonProps, Omit<DropdownMenuPro
|
|
|
6
6
|
children?: React.ReactNode;
|
|
7
7
|
caption?: string;
|
|
8
8
|
disableAnimations?: boolean;
|
|
9
|
+
/** @ignore */
|
|
9
10
|
_avatar?: React.ReactElement;
|
|
10
11
|
id?: string;
|
|
12
|
+
/** @ignore */
|
|
11
13
|
_generatedId?: string;
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
@@ -10,26 +10,32 @@ var SideMenuHeaderInner = forwardRef(function (_a, ref) {
|
|
|
10
10
|
var className = _a.className, productLogo = _a.productLogo, konturLogo = _a.konturLogo, iconUrl = _a.iconUrl, style = _a.style, withWidget = _a.withWidget, rest = __rest(_a, ["className", "productLogo", "konturLogo", "iconUrl", "style", "withWidget"]);
|
|
11
11
|
var context = useContext(SideMenuContext);
|
|
12
12
|
var headerWrapperRef = useRef(null);
|
|
13
|
-
var _c = useState(false),
|
|
13
|
+
var _c = useState(false), isFixed = _c[0], setIsFixed = _c[1];
|
|
14
14
|
var checkFixed = function () {
|
|
15
15
|
if (headerWrapperRef.current && headerWrapperRef.current.offsetTop > 0) {
|
|
16
|
-
|
|
16
|
+
setIsFixed(true);
|
|
17
17
|
}
|
|
18
18
|
else {
|
|
19
|
-
|
|
19
|
+
setIsFixed(false);
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
useEffect(function () {
|
|
23
|
-
|
|
23
|
+
if (!context.separatedMenuIsShown) {
|
|
24
|
+
window.addEventListener('scroll', checkFixed, true);
|
|
25
|
+
}
|
|
24
26
|
return function () {
|
|
25
27
|
window.removeEventListener('scroll', checkFixed, true);
|
|
26
28
|
};
|
|
27
29
|
});
|
|
30
|
+
useEffect(function () {
|
|
31
|
+
context.mobileSeparatedMenuIsScrolling !== undefined && setIsFixed(context.mobileSeparatedMenuIsScrolling);
|
|
32
|
+
}, [context.mobileSeparatedMenuIsScrolling]);
|
|
28
33
|
return (React.createElement("header", __assign({ className: cx((_b = {},
|
|
29
34
|
_b[jsStyles.headerWrapper()] = true,
|
|
30
|
-
_b[jsStyles.headerFixedWrapper()] =
|
|
35
|
+
_b[jsStyles.headerFixedWrapper()] = isFixed,
|
|
31
36
|
_b[jsStyles.headerMinimisedWrapper()] = context.isMinimised || context.isTransitioned,
|
|
32
|
-
_b[jsStyles.
|
|
37
|
+
_b[jsStyles.headerCollapsedWrapperForTabletsOrMobiles()] = !context.isShown,
|
|
38
|
+
_b[jsStyles.headerWithSeparatedMenuShown()] = context.isShown && context.isMobile && context.separatedMenuIsShown,
|
|
33
39
|
_b), className), ref: mergeRefs([headerWrapperRef, ref]), style: style }, rest),
|
|
34
40
|
React.createElement(SideMenuLogotype, __assign({ productLogo: productLogo, konturLogo: konturLogo, iconUrl: iconUrl, withWidget: withWidget }, rest))));
|
|
35
41
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const jsStyles: {
|
|
2
2
|
headerWrapper(): string;
|
|
3
3
|
headerMinimisedWrapper(): string;
|
|
4
|
-
|
|
4
|
+
headerCollapsedWrapperForTabletsOrMobiles(): string;
|
|
5
|
+
headerWithSeparatedMenuShown(): string;
|
|
5
6
|
headerFixedWrapper(): string;
|
|
6
7
|
};
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { __makeTemplateObject } from "tslib";
|
|
2
2
|
import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
var headerWrapperPaddingX = '8px';
|
|
3
4
|
var styles = {
|
|
4
5
|
headerWrapper: function () {
|
|
5
|
-
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: sticky;\n width:
|
|
6
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: sticky;\n width: calc(100% - 2 * ", ");\n top: 0;\n background: #f6f6f6;\n z-index: 1;\n padding: 24px ", " 16px;\n "], ["\n position: sticky;\n width: calc(100% - 2 * ", ");\n top: 0;\n background: #f6f6f6;\n z-index: 1;\n padding: 24px ", " 16px;\n "])), headerWrapperPaddingX, headerWrapperPaddingX);
|
|
6
7
|
},
|
|
7
8
|
headerMinimisedWrapper: function () {
|
|
8
9
|
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: 54px;\n padding-left: 0 !important;\n padding-right: 0;\n "], ["\n width: 54px;\n padding-left: 0 !important;\n padding-right: 0;\n "])));
|
|
9
10
|
},
|
|
10
|
-
|
|
11
|
+
headerCollapsedWrapperForTabletsOrMobiles: function () {
|
|
11
12
|
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background: transparent;\n "], ["\n background: transparent;\n "])));
|
|
12
13
|
},
|
|
14
|
+
headerWithSeparatedMenuShown: function () {
|
|
15
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n background: #fff;\n "], ["\n background: #fff;\n "])));
|
|
16
|
+
},
|
|
13
17
|
headerFixedWrapper: function () {
|
|
14
|
-
return css(
|
|
18
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n box-shadow: inset 0 -1px 0 #e6e6e6;\n "], ["\n box-shadow: inset 0 -1px 0 #e6e6e6;\n "])));
|
|
15
19
|
},
|
|
16
20
|
};
|
|
17
21
|
export var jsStyles = memoizeStyle(styles);
|
|
18
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
22
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -4,7 +4,7 @@ import { SideMenuItem } from '../SideMenuItem/SideMenuItem';
|
|
|
4
4
|
import { SideMenuContext } from '../SideMenuContext';
|
|
5
5
|
import { NestedMenu } from '../internal/NestedMenu';
|
|
6
6
|
import { useOpenedSubElementState } from '../../hooks/useOpenedSubElementState';
|
|
7
|
-
import { useMemoIcon } from '../../hooks/
|
|
7
|
+
import { useMemoIcon } from '../../hooks/useMemoIcon';
|
|
8
8
|
var SideMenuSubItemInner = forwardRef(function (_a, ref) {
|
|
9
9
|
var children = _a.children, _generatedId = _a._generatedId, id = _a.id, rest = __rest(_a, ["children", "_generatedId", "id"]);
|
|
10
10
|
var context = useContext(SideMenuContext);
|
|
@@ -4,7 +4,7 @@ import { SideMenuContext } from '../SideMenuContext';
|
|
|
4
4
|
import { SideMenuLink } from '../SideMenuLink/SideMenuLink';
|
|
5
5
|
import { NestedMenu } from '../internal/NestedMenu';
|
|
6
6
|
import { useOpenedSubElementState } from '../../hooks/useOpenedSubElementState';
|
|
7
|
-
import { useMemoIcon } from '../../hooks/
|
|
7
|
+
import { useMemoIcon } from '../../hooks/useMemoIcon';
|
|
8
8
|
var SideMenuSubLinkInner = forwardRef(function (_a, ref) {
|
|
9
9
|
var marker = _a.marker, id = _a.id, _generatedId = _a._generatedId, _isSubMenu = _a._isSubMenu, _isNestedSubMenu = _a._isNestedSubMenu, children = _a.children, rest = __rest(_a, ["marker", "id", "_generatedId", "_isSubMenu", "_isNestedSubMenu", "children"]);
|
|
10
10
|
var context = useContext(SideMenuContext);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface BackButtonProps {
|
|
3
|
+
caption?: string;
|
|
4
|
+
id?: string;
|
|
5
|
+
href?: string;
|
|
6
|
+
generatedId?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const BackButtonWithStaticFields: React.ForwardRefExoticComponent<BackButtonProps & React.RefAttributes<HTMLButtonElement>> & {
|
|
9
|
+
__KONTUR_REACT_UI__: string;
|
|
10
|
+
};
|
|
11
|
+
export { BackButtonWithStaticFields as BackButton };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { forwardRef, useContext } from 'react';
|
|
2
|
+
import { SideMenuDataTids } from '../../SideMenuDataTids';
|
|
3
|
+
import { ArrowALeftIcon20Regular } from '@skbkontur/icons';
|
|
4
|
+
import { SideMenuItem } from '../SideMenuItem/SideMenuItem';
|
|
5
|
+
import { SideMenuContext } from '../SideMenuContext';
|
|
6
|
+
/**
|
|
7
|
+
* Кнопка возврата в меню первого уровня
|
|
8
|
+
*
|
|
9
|
+
* @visibleName BackButton
|
|
10
|
+
*/
|
|
11
|
+
var BackButton = forwardRef(function (_a, ref) {
|
|
12
|
+
var caption = _a.caption, id = _a.id, href = _a.href, generatedId = _a.generatedId;
|
|
13
|
+
var context = useContext(SideMenuContext);
|
|
14
|
+
return (React.createElement(SideMenuItem, { "data-tid": SideMenuDataTids.backButton, icon: React.createElement(ArrowALeftIcon20Regular, null), caption: caption, _isDropdown: true, _isSubMenu: true, onClick: function () {
|
|
15
|
+
var _a, _b, _c, _d;
|
|
16
|
+
(_a = context.setSeparatedMenuIsShown) === null || _a === void 0 ? void 0 : _a.call(context, false);
|
|
17
|
+
if (id) {
|
|
18
|
+
(_b = context.switchActiveMenuItem) === null || _b === void 0 ? void 0 : _b.call(context, id);
|
|
19
|
+
}
|
|
20
|
+
else if (href) {
|
|
21
|
+
(_c = context.switchActiveMenuItem) === null || _c === void 0 ? void 0 : _c.call(context, href);
|
|
22
|
+
}
|
|
23
|
+
else if (generatedId) {
|
|
24
|
+
(_d = context.switchActiveMenuItem) === null || _d === void 0 ? void 0 : _d.call(context, generatedId);
|
|
25
|
+
}
|
|
26
|
+
}, _isBackButton: true, ref: ref }));
|
|
27
|
+
});
|
|
28
|
+
BackButton.displayName = 'BackButton';
|
|
29
|
+
var BackButtonWithStaticFields = Object.assign(BackButton, { __KONTUR_REACT_UI__: 'BackButton' });
|
|
30
|
+
export { BackButtonWithStaticFields as BackButton };
|
package/src/internal/Backdrop.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { HideBodyVerticalScroll } from '@skbkontur/react-ui/internal/HideBodyVerticalScroll';
|
|
3
|
-
import { ZIndex } from '@skbkontur/react-ui/internal/ZIndex';
|
|
4
3
|
import { jsStyles } from './Backdrop.styles';
|
|
5
4
|
import { DEFAULT_THEME } from '@skbkontur/react-ui';
|
|
5
|
+
import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
6
6
|
export var Backdrop = function () {
|
|
7
|
-
|
|
7
|
+
var _a;
|
|
8
|
+
return (React.createElement("div", { className: cx((_a = {},
|
|
9
|
+
_a[jsStyles.backdropForTabletsOrMobiles()] = true,
|
|
10
|
+
_a)), style: {
|
|
8
11
|
background: DEFAULT_THEME.sidePageBackingBg,
|
|
9
12
|
opacity: DEFAULT_THEME.sidePageBackingBgOpacity,
|
|
10
13
|
} },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __makeTemplateObject } from "tslib";
|
|
2
2
|
import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
3
|
var styles = {
|
|
4
|
-
|
|
4
|
+
backdropForTabletsOrMobiles: function () {
|
|
5
5
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n "], ["\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n "])));
|
|
6
6
|
},
|
|
7
7
|
};
|
package/src/internal/Burger.js
CHANGED
|
@@ -2,9 +2,9 @@ import React, { useContext } from 'react';
|
|
|
2
2
|
import { jsStyles } from './Burger.styles';
|
|
3
3
|
import { SideMenuContext } from '../SideMenuContext';
|
|
4
4
|
import { UiMenuBarsThreeHIcon24Regular } from '@skbkontur/icons';
|
|
5
|
-
import { SideMenuDataTids } from '
|
|
5
|
+
import { SideMenuDataTids } from '../../SideMenuDataTids';
|
|
6
6
|
export var Burger = function () {
|
|
7
7
|
var context = useContext(SideMenuContext);
|
|
8
|
-
return (React.createElement("button", { className: jsStyles.
|
|
8
|
+
return (React.createElement("button", { className: jsStyles.burgerWrapperForTabletsOrMobiles(), onClick: context.toggleIsShown, "data-tid": SideMenuDataTids.burger },
|
|
9
9
|
React.createElement(UiMenuBarsThreeHIcon24Regular, null)));
|
|
10
10
|
};
|
|
@@ -2,7 +2,7 @@ import { __makeTemplateObject } from "tslib";
|
|
|
2
2
|
import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
3
|
import { resetButton } from '@skbkontur/react-ui/lib/styles/Mixins';
|
|
4
4
|
var styles = {
|
|
5
|
-
|
|
5
|
+
burgerWrapperForTabletsOrMobiles: function () {
|
|
6
6
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n margin-right: 8px;\n "], ["\n ", ";\n margin-right: 8px;\n "])), resetButton());
|
|
7
7
|
},
|
|
8
8
|
};
|
|
@@ -6,11 +6,18 @@ export interface CommonClickableElementProps extends CommonProps {
|
|
|
6
6
|
marker?: string;
|
|
7
7
|
caption?: string;
|
|
8
8
|
id?: string;
|
|
9
|
+
/** @ignore */
|
|
9
10
|
_generatedId?: string;
|
|
11
|
+
/** @ignore */
|
|
10
12
|
_isSubMenu?: boolean;
|
|
13
|
+
/** @ignore */
|
|
11
14
|
_isNestedSubMenu?: boolean;
|
|
15
|
+
/** @ignore */
|
|
12
16
|
_avatar?: React.ReactElement;
|
|
17
|
+
/** @ignore */
|
|
13
18
|
_isDropdown?: boolean;
|
|
19
|
+
/** @ignore */
|
|
20
|
+
_isBackButton?: boolean;
|
|
14
21
|
}
|
|
15
22
|
export interface ClickableElementProps extends CommonClickableElementProps {
|
|
16
23
|
element: 'a' | 'button';
|
|
@@ -15,11 +15,11 @@ import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
|
15
15
|
*/
|
|
16
16
|
var ClickableElement = forwardRef(function (_a, ref) {
|
|
17
17
|
var _b;
|
|
18
|
-
var onClick = _a.onClick, icon = _a.icon, _avatar = _a._avatar, marker = _a.marker, caption = _a.caption, id = _a.id, _isSubMenu = _a._isSubMenu, children = _a.children, _isNestedSubMenu = _a._isNestedSubMenu, _generatedId = _a._generatedId, Tag = _a.element, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onBlur = _a.onBlur, className = _a.className, _isDropdown = _a._isDropdown, rest = __rest(_a, ["onClick", "icon", "_avatar", "marker", "caption", "id", "_isSubMenu", "children", "_isNestedSubMenu", "_generatedId", "element", "onKeyDown", "onFocus", "onBlur", "className", "_isDropdown"]);
|
|
18
|
+
var onClick = _a.onClick, icon = _a.icon, _avatar = _a._avatar, marker = _a.marker, caption = _a.caption, id = _a.id, _isSubMenu = _a._isSubMenu, children = _a.children, _isNestedSubMenu = _a._isNestedSubMenu, _generatedId = _a._generatedId, Tag = _a.element, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onBlur = _a.onBlur, className = _a.className, _isDropdown = _a._isDropdown, _isBackButton = _a._isBackButton, rest = __rest(_a, ["onClick", "icon", "_avatar", "marker", "caption", "id", "_isSubMenu", "children", "_isNestedSubMenu", "_generatedId", "element", "onKeyDown", "onFocus", "onBlur", "className", "_isDropdown", "_isBackButton"]);
|
|
19
19
|
var context = useContext(SideMenuContext);
|
|
20
20
|
var isActive = useActiveState(id, rest.href, _generatedId, context.activeMenuItem);
|
|
21
21
|
var _c = useState(false), focusedByTab = _c[0], setFocusedByTab = _c[1];
|
|
22
|
-
var isOpened = useOpenedState(id || rest.href, _generatedId, context.openedParents, isActive, children);
|
|
22
|
+
var isOpened = useOpenedState(id || rest.href, _generatedId, context.openedParents, isActive, children, context.separatedMenuIsShown, context.isMobile && context.isSeparatedMenu);
|
|
23
23
|
var hasChildren = function (id, generatedId) {
|
|
24
24
|
var _a, _b;
|
|
25
25
|
var parentId = id ? 'id' : 'generatedParentId';
|
|
@@ -27,7 +27,7 @@ var ClickableElement = forwardRef(function (_a, ref) {
|
|
|
27
27
|
return (_b = (_a = context.flattedArrayOfAllElements) === null || _a === void 0 ? void 0 : _a.filter(function (el) { return el[parentId] === childId; })) === null || _b === void 0 ? void 0 : _b.length;
|
|
28
28
|
};
|
|
29
29
|
var handleClick = function (e) {
|
|
30
|
-
var _a, _b, _c, _d;
|
|
30
|
+
var _a, _b, _c, _d, _e;
|
|
31
31
|
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
32
32
|
if (id) {
|
|
33
33
|
(_a = context.switchActiveMenuItem) === null || _a === void 0 ? void 0 : _a.call(context, id);
|
|
@@ -41,6 +41,9 @@ var ClickableElement = forwardRef(function (_a, ref) {
|
|
|
41
41
|
if (!hasChildren(id || rest.href, _generatedId) && !_isDropdown) {
|
|
42
42
|
(_d = context.toggleIsShown) === null || _d === void 0 ? void 0 : _d.call(context);
|
|
43
43
|
}
|
|
44
|
+
if (context.isSeparatedMenu && !_isSubMenu && children) {
|
|
45
|
+
(_e = context.setSeparatedMenuIsShown) === null || _e === void 0 ? void 0 : _e.call(context, true);
|
|
46
|
+
}
|
|
44
47
|
};
|
|
45
48
|
var handleFocus = function (e) {
|
|
46
49
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
@@ -62,8 +65,8 @@ var ClickableElement = forwardRef(function (_a, ref) {
|
|
|
62
65
|
_b[jsStyles.focusedClickableElement()] = focusedByTab,
|
|
63
66
|
_b[jsStyles.activeClickableElement()] = isActive || isOpenedFirstLevelItemInSeparatedMenu,
|
|
64
67
|
_b[jsStyles.activeClickableSubElement()] = isActive && context.isSeparatedMenu && _isSubMenu,
|
|
65
|
-
_b), className), onClick: handleClick, onFocus: handleFocus, onBlur: handleBlur, children: (React.createElement(ItemContent, { _isSubMenu: _isSubMenu, icon: icon, _isNestedSubMenu: _isNestedSubMenu, caption: caption, marker: marker, _avatar: _avatar })), ref: ref }, rest)),
|
|
66
|
-
React.createElement(SubMenu, { generatedId: _generatedId, isSubMenu: _isSubMenu, isSeparatedMenu: context.isSeparatedMenu, isOpened: isOpened, isMinimised: context.isMinimised }, children)));
|
|
68
|
+
_b), className), onClick: handleClick, onFocus: handleFocus, onBlur: handleBlur, children: (React.createElement(ItemContent, { _isSubMenu: _isSubMenu, icon: icon, _isNestedSubMenu: _isNestedSubMenu, caption: caption, marker: marker, _avatar: _avatar, _isBackButton: _isBackButton })), ref: ref }, rest)),
|
|
69
|
+
React.createElement(SubMenu, { generatedId: _generatedId, id: id, href: rest.href, caption: caption, isSubMenu: _isSubMenu, isSeparatedMenu: context.isSeparatedMenu, isOpened: isOpened, isMinimised: context.isMinimised }, children)));
|
|
67
70
|
});
|
|
68
71
|
ClickableElement.displayName = 'ClickableElement';
|
|
69
72
|
var ClickableElementWithStaticFields = Object.assign(ClickableElement, {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
interface CaptionProps extends Pick<ItemContentProps, '_isSubMenu' | '_isNestedSubMenu' | 'caption'>, Pick<SideMenuContextType, 'isTransitioned' | 'isSeparatedMenu' | 'hasSubIcons' | 'size'> {
|
|
2
|
+
import { SideMenuItemProps } from '../../SideMenuItem/SideMenuItem';
|
|
3
|
+
interface CaptionProps extends Pick<SideMenuItemProps, '_isSubMenu' | '_isNestedSubMenu' | 'caption' | '_isBackButton'> {
|
|
5
4
|
hasShortcutImage: boolean;
|
|
6
5
|
isMultiline: boolean;
|
|
7
6
|
}
|
|
@@ -4,8 +4,9 @@ import React, { forwardRef, useContext } from 'react';
|
|
|
4
4
|
import { SideMenuContext } from '../../SideMenuContext';
|
|
5
5
|
export var Caption = forwardRef(function (_a, ref) {
|
|
6
6
|
var _b;
|
|
7
|
-
var
|
|
7
|
+
var _isSubMenu = _a._isSubMenu, _isNestedSubMenu = _a._isNestedSubMenu, hasShortcutImage = _a.hasShortcutImage, caption = _a.caption, isMultiline = _a.isMultiline, _isBackButton = _a._isBackButton;
|
|
8
8
|
var context = useContext(SideMenuContext);
|
|
9
|
+
var isTransitioned = context.isTransitioned, isSeparatedMenu = context.isSeparatedMenu, size = context.size, isTouchScreen = context.isTouchScreen, hasSubIcons = context.hasSubIcons;
|
|
9
10
|
return (React.createElement("p", { className: cx((_b = {},
|
|
10
11
|
_b[jsStyles.caption()] = true,
|
|
11
12
|
_b[jsStyles.captionTransitioned()] = isTransitioned,
|
|
@@ -16,8 +17,9 @@ export var Caption = forwardRef(function (_a, ref) {
|
|
|
16
17
|
_b[jsStyles.subCaptionWithoutColumnIcons()] = _isSubMenu && isSeparatedMenu && !hasSubIcons,
|
|
17
18
|
_b[jsStyles.captionLarge()] = size === 'large',
|
|
18
19
|
_b[jsStyles.captionMultiline()] = isMultiline,
|
|
19
|
-
_b[jsStyles.captionForTouchScreens()] =
|
|
20
|
-
_b[jsStyles.subCaptionForTouchScreens()] =
|
|
20
|
+
_b[jsStyles.captionForTouchScreens()] = isTouchScreen,
|
|
21
|
+
_b[jsStyles.subCaptionForTouchScreens()] = isTouchScreen && _isSubMenu,
|
|
22
|
+
_b[jsStyles.captionInBackButton()] = _isBackButton,
|
|
21
23
|
_b)), ref: ref }, caption));
|
|
22
24
|
});
|
|
23
25
|
Caption.displayName = 'Caption';
|
|
@@ -34,6 +34,9 @@ var styles = {
|
|
|
34
34
|
captionLarge: function () {
|
|
35
35
|
return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n font-size: 16px !important;\n line-height: 22px !important;\n "], ["\n font-size: 16px !important;\n line-height: 22px !important;\n "])));
|
|
36
36
|
},
|
|
37
|
+
captionInBackButton: function () {
|
|
38
|
+
return css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n font-weight: 700;\n font-size: 20px;\n line-height: 28px;\n padding-top: 5px;\n padding-bottom: 5px;\n "], ["\n font-weight: 700;\n font-size: 20px;\n line-height: 28px;\n padding-top: 5px;\n padding-bottom: 5px;\n "])));
|
|
39
|
+
},
|
|
37
40
|
};
|
|
38
41
|
export var jsStyles = memoizeStyle(styles);
|
|
39
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11;
|
|
42
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
interface IconProps extends Pick<ItemContentProps, '_isSubMenu' | 'icon'>, Pick<SideMenuContextType, 'isSeparatedMenu' | 'size'> {
|
|
2
|
+
import { SideMenuItemProps } from '../../SideMenuItem/SideMenuItem';
|
|
3
|
+
interface IconProps extends Pick<SideMenuItemProps, '_isSubMenu' | 'icon' | '_isBackButton'> {
|
|
5
4
|
isMultiline: boolean;
|
|
6
5
|
}
|
|
7
|
-
export declare const Icon: ({ icon, _isSubMenu, isMultiline,
|
|
6
|
+
export declare const Icon: ({ icon, _isSubMenu, isMultiline, _isBackButton }: IconProps) => React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>;
|
|
8
7
|
export {};
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
2
|
import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
3
|
import { jsStyles } from './Icon.styles';
|
|
4
|
+
import { SideMenuContext } from '../../SideMenuContext';
|
|
5
|
+
import { getIconSize } from '../../../utils/scripts';
|
|
4
6
|
export var Icon = function (_a) {
|
|
5
7
|
var _b;
|
|
6
|
-
var icon = _a.icon, _isSubMenu = _a._isSubMenu, isMultiline = _a.isMultiline,
|
|
8
|
+
var icon = _a.icon, _isSubMenu = _a._isSubMenu, isMultiline = _a.isMultiline, _c = _a._isBackButton, _isBackButton = _c === void 0 ? false : _c;
|
|
9
|
+
var context = useContext(SideMenuContext);
|
|
10
|
+
var isSeparatedMenu = context.isSeparatedMenu, size = context.size;
|
|
7
11
|
return React.cloneElement(icon, {
|
|
8
|
-
size: _isSubMenu
|
|
9
|
-
|
|
12
|
+
size: getIconSize(_isSubMenu, _isBackButton),
|
|
13
|
+
color: _isSubMenu ? '#858585' : undefined,
|
|
14
|
+
disableCompensation: !_isBackButton,
|
|
10
15
|
className: cx((_b = {},
|
|
11
16
|
_b[jsStyles.icon()] = true,
|
|
12
17
|
_b[jsStyles.iconMultiline()] = isMultiline,
|
|
@@ -15,6 +20,7 @@ export var Icon = function (_a) {
|
|
|
15
20
|
_b[jsStyles.iconSubItem()] = _isSubMenu,
|
|
16
21
|
_b[jsStyles.iconSubItemSeparatedMenu()] = isSeparatedMenu && _isSubMenu,
|
|
17
22
|
_b[jsStyles.iconSubItemLarge()] = _isSubMenu && size === 'large',
|
|
23
|
+
_b[jsStyles.iconBackButton()] = _isBackButton,
|
|
18
24
|
_b)),
|
|
19
25
|
});
|
|
20
26
|
};
|
|
@@ -22,6 +22,9 @@ var styles = {
|
|
|
22
22
|
iconSubItemSeparatedMenu: function () {
|
|
23
23
|
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n padding-left: 4px;\n "], ["\n padding-left: 4px;\n "])));
|
|
24
24
|
},
|
|
25
|
+
iconBackButton: function () {
|
|
26
|
+
return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n padding-left: 10px;\n padding-right: 6px;\n "], ["\n padding-left: 10px;\n padding-right: 6px;\n "])));
|
|
27
|
+
},
|
|
25
28
|
};
|
|
26
29
|
export var jsStyles = memoizeStyle(styles);
|
|
27
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
30
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SideMenuItemProps } from '../../SideMenuItem/SideMenuItem';
|
|
3
|
-
|
|
4
|
-
declare const ItemContentWithStaticFields: React.ForwardRefExoticComponent<Pick<SideMenuItemProps, "caption" | "marker" | "_isSubMenu" | "icon" | "_isNestedSubMenu" | "_avatar"> & React.RefAttributes<HTMLDivElement>> & {
|
|
3
|
+
declare const ItemContentWithStaticFields: React.ForwardRefExoticComponent<SideMenuItemProps & React.RefAttributes<HTMLDivElement>> & {
|
|
5
4
|
__KONTUR_REACT_UI__: string;
|
|
6
5
|
};
|
|
7
6
|
export { ItemContentWithStaticFields as ItemContent };
|
|
@@ -12,12 +12,12 @@ import { Avatar } from './Avatar';
|
|
|
12
12
|
*/
|
|
13
13
|
var ItemContent = forwardRef(function (_a, ref) {
|
|
14
14
|
var _b;
|
|
15
|
-
var _isSubMenu = _a._isSubMenu, icon = _a.icon, _isNestedSubMenu = _a._isNestedSubMenu, caption = _a.caption, marker = _a.marker, _avatar = _a._avatar;
|
|
15
|
+
var _isSubMenu = _a._isSubMenu, icon = _a.icon, _isNestedSubMenu = _a._isNestedSubMenu, caption = _a.caption, marker = _a.marker, _avatar = _a._avatar, _isBackButton = _a._isBackButton;
|
|
16
16
|
var context = useContext(SideMenuContext);
|
|
17
17
|
var textRef = useRef(null);
|
|
18
18
|
var _c = useState(false), isMultiline = _c[0], setIsMultiline = _c[1];
|
|
19
19
|
useEffect(function () {
|
|
20
|
-
useNumberOfTextLinesInItem(textRef, setIsMultiline);
|
|
20
|
+
!_isBackButton && useNumberOfTextLinesInItem(textRef, setIsMultiline);
|
|
21
21
|
}, [textRef.current]);
|
|
22
22
|
var hasShortcutImage = !!icon || !!_avatar;
|
|
23
23
|
return (React.createElement("div", { className: cx((_b = {},
|
|
@@ -30,10 +30,10 @@ var ItemContent = forwardRef(function (_a, ref) {
|
|
|
30
30
|
_b[jsStyles.itemWrapperForTouchScreens()] = context.isTouchScreen,
|
|
31
31
|
_b[jsStyles.subItemWrapperForTouchScreens()] = context.isTouchScreen && _isSubMenu,
|
|
32
32
|
_b)), ref: ref },
|
|
33
|
-
icon &&
|
|
33
|
+
icon && React.createElement(Icon, { icon: icon, _isSubMenu: _isSubMenu, isMultiline: isMultiline, _isBackButton: _isBackButton }),
|
|
34
34
|
_avatar && React.createElement(Avatar, { _avatar: _avatar }),
|
|
35
35
|
!context.isMinimised && (React.createElement("div", { className: jsStyles.textAndMarkerWrapper() },
|
|
36
|
-
React.createElement(Caption, {
|
|
36
|
+
React.createElement(Caption, { _isSubMenu: _isSubMenu, _isNestedSubMenu: _isNestedSubMenu, hasShortcutImage: hasShortcutImage, isMultiline: isMultiline, caption: caption, _isBackButton: _isBackButton, ref: textRef }),
|
|
37
37
|
marker && React.createElement(Marker, { isMultiline: isMultiline, marker: marker })))));
|
|
38
38
|
});
|
|
39
39
|
ItemContent.displayName = 'ItemContent';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
interface MarkerProps extends Pick<
|
|
1
|
+
import { SideMenuItemProps } from '../../SideMenuItem/SideMenuItem';
|
|
2
|
+
interface MarkerProps extends Pick<SideMenuItemProps, 'marker'> {
|
|
3
3
|
isMultiline: boolean;
|
|
4
4
|
}
|
|
5
5
|
export declare const Marker: ({ isMultiline, marker }: MarkerProps) => JSX.Element;
|
|
@@ -2,6 +2,9 @@ import React from 'react';
|
|
|
2
2
|
interface SeparatedSubMenuProps {
|
|
3
3
|
children?: React.ReactNode;
|
|
4
4
|
generatedId?: string;
|
|
5
|
+
id?: string;
|
|
6
|
+
href?: string;
|
|
7
|
+
caption?: string;
|
|
5
8
|
}
|
|
6
9
|
declare const SeparatedSubMenuWithStaticFields: React.ForwardRefExoticComponent<SeparatedSubMenuProps & React.RefAttributes<HTMLDivElement>> & {
|
|
7
10
|
__KONTUR_REACT_UI__: string;
|
|
@@ -5,6 +5,10 @@ import { jsStyles } from '../SideMenu/SideMenu.styles';
|
|
|
5
5
|
import { jsStylesForSeparatedSubMenu } from './SeparatedSubMenu.styles';
|
|
6
6
|
import { SideMenuContext } from '../SideMenuContext';
|
|
7
7
|
import { isClickableSubElement } from '../../utils/scripts';
|
|
8
|
+
import { BackButton } from './BackButton';
|
|
9
|
+
import { mergeRefs } from '@skbkontur/react-ui/lib/utils';
|
|
10
|
+
import { SideMenuDataTids } from '../../SideMenuDataTids';
|
|
11
|
+
import { useMobileSeparatedMenuScroll } from '../../hooks/useMobileSeparatedMenuScroll';
|
|
8
12
|
/**
|
|
9
13
|
* Отдельностоящее подменю
|
|
10
14
|
*
|
|
@@ -12,7 +16,7 @@ import { isClickableSubElement } from '../../utils/scripts';
|
|
|
12
16
|
*/
|
|
13
17
|
var SeparatedSubMenu = forwardRef(function (_a, ref) {
|
|
14
18
|
var _b;
|
|
15
|
-
var children = _a.children, generatedId = _a.generatedId;
|
|
19
|
+
var children = _a.children, generatedId = _a.generatedId, id = _a.id, href = _a.href, caption = _a.caption;
|
|
16
20
|
var context = useContext(SideMenuContext);
|
|
17
21
|
var isSubItemWithChildren = function (child) {
|
|
18
22
|
// @ts-expect-error: accessing private property
|
|
@@ -26,12 +30,15 @@ var SeparatedSubMenu = forwardRef(function (_a, ref) {
|
|
|
26
30
|
return child;
|
|
27
31
|
});
|
|
28
32
|
};
|
|
33
|
+
var separatedMenuRef = useMobileSeparatedMenuScroll();
|
|
29
34
|
var levelIndex = 0;
|
|
30
35
|
return (React.createElement("div", { className: cx((_b = {},
|
|
31
36
|
_b[jsStyles.root()] = true,
|
|
32
37
|
_b[jsStyles.rootForTouchScreens()] = context.isTouchScreen,
|
|
33
38
|
_b[jsStylesForSeparatedSubMenu.separatedSubMenu()] = true,
|
|
34
|
-
_b)
|
|
39
|
+
_b[jsStylesForSeparatedSubMenu.separatedSubMenuForMobiles()] = context.isMobile,
|
|
40
|
+
_b)), ref: mergeRefs([separatedMenuRef, ref]), "data-tid": SideMenuDataTids.separatedSubMenu },
|
|
41
|
+
context.isMobile && React.createElement(BackButton, { caption: caption, id: id, href: href, generatedId: generatedId }),
|
|
35
42
|
React.createElement(SideMenuContext.Provider, { value: __assign({ hasSubIcons: hasSubItems(children) }, context) }, React.Children.map(children, function (child) {
|
|
36
43
|
if (React.isValidElement(child)) {
|
|
37
44
|
if (
|
|
@@ -4,6 +4,10 @@ var styles = {
|
|
|
4
4
|
separatedSubMenu: function () {
|
|
5
5
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n z-index: 8000;\n background: #fff;\n left: 100%;\n overflow: auto;\n justify-content: flex-start;\n padding: 24px 16px;\n border-right: 1px solid #e5e5e5;\n "], ["\n position: absolute;\n top: 0;\n z-index: 8000;\n background: #fff;\n left: 100%;\n overflow: auto;\n justify-content: flex-start;\n padding: 24px 16px;\n border-right: 1px solid #e5e5e5;\n "])));
|
|
6
6
|
},
|
|
7
|
+
separatedSubMenuForMobiles: function () {
|
|
8
|
+
var headerHeight = '68px';
|
|
9
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n height: calc(100vh - ", ");\n left: 0;\n top: ", ";\n padding-top: 0;\n "], ["\n height: calc(100vh - ", ");\n left: 0;\n top: ", ";\n padding-top: 0;\n "])), headerHeight, headerHeight);
|
|
10
|
+
},
|
|
7
11
|
};
|
|
8
12
|
export var jsStylesForSeparatedSubMenu = memoizeStyle(styles);
|
|
9
|
-
var templateObject_1;
|
|
13
|
+
var templateObject_1, templateObject_2;
|
|
@@ -32,8 +32,11 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
|
|
|
32
32
|
.join('');
|
|
33
33
|
};
|
|
34
34
|
var getProductName = function () {
|
|
35
|
+
var _a;
|
|
35
36
|
// @ts-expect-error: accessing private property
|
|
36
|
-
return productLogo ?
|
|
37
|
+
return ((_a = productLogo === null || productLogo === void 0 ? void 0 : productLogo.type) === null || _a === void 0 ? void 0 : _a.__KONTUR_REACT_UI__) ? // @ts-expect-error: accessing private property
|
|
38
|
+
changeCamelCaseToKebabCase(productLogo.type.__KONTUR_REACT_UI__)
|
|
39
|
+
: 'kontur';
|
|
37
40
|
};
|
|
38
41
|
var productName = getProductName();
|
|
39
42
|
var getStaticIconPath = function () {
|
|
@@ -42,18 +45,18 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
|
|
|
42
45
|
if (context.isMinimised || context.isTransitioned) {
|
|
43
46
|
return React.createElement("img", { className: jsStyles.logotypeIcon(), src: iconUrl || getStaticIconPath(), alt: productName });
|
|
44
47
|
}
|
|
45
|
-
var getWidget = function (withWidget,
|
|
48
|
+
var getWidget = function (withWidget, isTouchScreen, showWidget) {
|
|
46
49
|
if (withWidget !== undefined) {
|
|
47
50
|
return withWidget;
|
|
48
51
|
}
|
|
49
|
-
if (
|
|
52
|
+
if (isTouchScreen) {
|
|
50
53
|
return true;
|
|
51
54
|
}
|
|
52
55
|
return showWidget;
|
|
53
56
|
};
|
|
54
57
|
return (React.createElement("div", { className: jsStyles.logotypeWrapper(), ref: ref },
|
|
55
|
-
context.isTablet && React.createElement(Burger, null),
|
|
56
|
-
React.createElement(Logotype, __assign({ ref: refLogotype, size: size, productLogo: productLogo, konturLogo: konturLogo, withWidget: getWidget(withWidget, context.
|
|
58
|
+
(context.isTablet || context.isMobile) && React.createElement(Burger, null),
|
|
59
|
+
React.createElement(Logotype, __assign({ ref: refLogotype, size: size, productLogo: productLogo, konturLogo: konturLogo, withWidget: getWidget(withWidget, context.isTouchScreen, context.showWidget) }, rest))));
|
|
57
60
|
});
|
|
58
61
|
SideMenuLogotype.displayName = 'SideMenuLogotype';
|
|
59
62
|
var SideMenuLogotypeWithStaticFields = Object.assign(SideMenuLogotype, { __KONTUR_REACT_UI__: 'SideMenuLogotype' });
|
|
@@ -6,6 +6,9 @@ interface SubMenuProps {
|
|
|
6
6
|
isSubMenu?: boolean;
|
|
7
7
|
isMinimised?: boolean;
|
|
8
8
|
isSeparatedMenu?: boolean;
|
|
9
|
+
id?: string;
|
|
10
|
+
href?: string;
|
|
11
|
+
caption?: string;
|
|
9
12
|
}
|
|
10
13
|
declare const SubMenuWithStaticFields: React.ForwardRefExoticComponent<SubMenuProps & React.RefAttributes<HTMLDivElement>> & {
|
|
11
14
|
__KONTUR_REACT_UI__: string;
|
package/src/internal/SubMenu.js
CHANGED
|
@@ -7,12 +7,12 @@ import { InnerSubMenu } from './InnerSubMenu';
|
|
|
7
7
|
* @visibleName InnerSubMenu
|
|
8
8
|
*/
|
|
9
9
|
var SubMenu = forwardRef(function (_a, ref) {
|
|
10
|
-
var children = _a.children, isOpened = _a.isOpened, isSubMenu = _a.isSubMenu, isMinimised = _a.isMinimised, isSeparatedMenu = _a.isSeparatedMenu, generatedId = _a.generatedId;
|
|
10
|
+
var children = _a.children, isOpened = _a.isOpened, isSubMenu = _a.isSubMenu, isMinimised = _a.isMinimised, isSeparatedMenu = _a.isSeparatedMenu, generatedId = _a.generatedId, id = _a.id, href = _a.href, caption = _a.caption;
|
|
11
11
|
if (!children || !isOpened || isSubMenu || isMinimised) {
|
|
12
12
|
return null;
|
|
13
13
|
}
|
|
14
14
|
if (isSeparatedMenu) {
|
|
15
|
-
return (React.createElement(SeparatedSubMenu, { generatedId: generatedId, ref: ref }, children));
|
|
15
|
+
return (React.createElement(SeparatedSubMenu, { generatedId: generatedId, id: id, href: href, ref: ref, caption: caption }, children));
|
|
16
16
|
}
|
|
17
17
|
return (React.createElement(InnerSubMenu, { generatedId: generatedId, ref: ref }, children));
|
|
18
18
|
});
|
package/utils/scripts.d.ts
CHANGED
|
@@ -9,3 +9,4 @@ export declare const getElementsChildren: (element: ReactElement, levelIndex: st
|
|
|
9
9
|
export declare const isParentOpened: (id: string | undefined, generatedId: string | undefined, openedParents: string[] | undefined) => boolean | "" | undefined;
|
|
10
10
|
export declare const isIdActive: (id: string | undefined, activeMenuItem: string | undefined | null) => boolean;
|
|
11
11
|
export declare const isTouchScreen: () => boolean;
|
|
12
|
+
export declare const getIconSize: (_isSubMenu?: boolean | undefined, _isBackButton?: boolean | undefined) => 24 | 16 | undefined;
|
package/utils/scripts.js
CHANGED
|
@@ -75,3 +75,11 @@ export var isIdActive = function (id, activeMenuItem) {
|
|
|
75
75
|
export var isTouchScreen = function () {
|
|
76
76
|
return typeof window !== undefined && ('ontouchstart' in window || navigator.maxTouchPoints > 0);
|
|
77
77
|
};
|
|
78
|
+
export var getIconSize = function (_isSubMenu, _isBackButton) {
|
|
79
|
+
if (!_isSubMenu) {
|
|
80
|
+
return 24;
|
|
81
|
+
}
|
|
82
|
+
if (!_isBackButton) {
|
|
83
|
+
return 16;
|
|
84
|
+
}
|
|
85
|
+
};
|