@skbkontur/side-menu 0.7.4 → 0.8.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/hooks/useAnimateOnMount.d.ts +2 -0
- package/hooks/useAnimateOnMount.js +18 -0
- package/hooks/useNumberOfTextLinesInItem.d.ts +1 -1
- package/hooks/useNumberOfTextLinesInItem.js +35 -10
- package/hooks/useNumberOfTextLinesInSubItem.d.ts +2 -0
- package/hooks/useNumberOfTextLinesInSubItem.js +13 -0
- package/package.json +1 -1
- package/src/SideMenu/SideMenu.d.ts +2 -0
- package/src/SideMenu/SideMenu.js +47 -20
- package/src/SideMenu/SideMenu.styles.d.ts +0 -1
- package/src/SideMenu/SideMenu.styles.js +14 -16
- package/src/SideMenuDropdown/SideMenuDropdown.styles.js +2 -1
- package/src/SideMenuFooter/SideMenuFooter.js +5 -1
- package/src/SideMenuFooter/SideMenuFooter.styles.d.ts +1 -0
- package/src/SideMenuFooter/SideMenuFooter.styles.js +4 -1
- package/src/SideMenuHeader/SideMenuHeader.js +2 -1
- package/src/SideMenuHeader/SideMenuHeader.styles.d.ts +1 -0
- package/src/SideMenuHeader/SideMenuHeader.styles.js +9 -7
- package/src/internal/Backdrop.d.ts +4 -1
- package/src/internal/Backdrop.js +3 -5
- package/src/internal/Backdrop.styles.js +2 -1
- package/src/internal/ClickableElement.styles.js +1 -1
- package/src/internal/ItemContent/Caption.js +2 -2
- package/src/internal/ItemContent/Caption.styles.js +1 -1
- package/src/internal/ItemContent/Icon.js +1 -2
- package/src/internal/ItemContent/Icon.styles.d.ts +0 -1
- package/src/internal/ItemContent/Icon.styles.js +6 -9
- package/src/internal/ItemContent/ItemContent.js +24 -7
- package/src/internal/ItemContent/ItemContent.styles.d.ts +4 -1
- package/src/internal/ItemContent/ItemContent.styles.js +18 -11
- package/src/internal/ItemContent/Marker.styles.js +1 -1
- package/src/internal/SideMenuLogotype.js +14 -6
- package/src/internal/SideMenuLogotype.styles.d.ts +5 -1
- package/src/internal/SideMenuLogotype.styles.js +19 -4
- package/src/internal/SubMenu.js +1 -1
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.8.0](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@0.7.4...@skbkontur/side-menu@0.8.0) (2023-03-31)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **SideMenu:** improve minimize animation ([acc6f27](https://git.skbkontur.ru/ui/ui-parking/commits/acc6f27df7c96a8a4e0fc6d595c40ad962a75b4d))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [0.7.4](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@0.7.3...@skbkontur/side-menu@0.7.4) (2023-03-30)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @skbkontur/side-menu
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
export function useAnimateOnMount(isMounted, delayTime, mountStyles, unmountStyles) {
|
|
3
|
+
var _a = useState(isMounted ? mountStyles : unmountStyles), style = _a[0], setStyle = _a[1];
|
|
4
|
+
var _b = useState(isMounted), shouldShowComponent = _b[0], setShouldShowComponent = _b[1];
|
|
5
|
+
useEffect(function () {
|
|
6
|
+
var timeoutId;
|
|
7
|
+
if (isMounted) {
|
|
8
|
+
setShouldShowComponent(true);
|
|
9
|
+
timeoutId = setTimeout(function () { return setStyle(mountStyles); }, 0);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
timeoutId = setTimeout(function () { return setShouldShowComponent(false); }, delayTime);
|
|
13
|
+
setStyle(unmountStyles);
|
|
14
|
+
}
|
|
15
|
+
return function () { return clearTimeout(timeoutId); };
|
|
16
|
+
}, [isMounted, delayTime]);
|
|
17
|
+
return [shouldShowComponent, style];
|
|
18
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare const useNumberOfTextLinesInItem: (textRef: React.RefObject<HTMLDivElement>,
|
|
2
|
+
export declare const useNumberOfTextLinesInItem: (textRef: React.RefObject<HTMLDivElement>, setLinesNumber: React.Dispatch<React.SetStateAction<number>>, text?: string, marker?: string, size?: string) => void;
|
|
@@ -1,13 +1,38 @@
|
|
|
1
|
-
export var useNumberOfTextLinesInItem = function (textRef,
|
|
2
|
-
if (
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
export var useNumberOfTextLinesInItem = function (textRef, setLinesNumber, text, marker, size) {
|
|
2
|
+
if (text === void 0) { text = ''; }
|
|
3
|
+
if (marker === void 0) { marker = ''; }
|
|
4
|
+
if (size === void 0) { size = 'small'; }
|
|
5
|
+
var getContainerWidth = function (ctx, marker) {
|
|
6
|
+
var containerWidth = 232 - 2 * 16 - 24 - 2 * 8; //TODO после перехода на переменные темы заменить на формулу: side-menu-width - 2 * side-menu-paddingX - iconWidth - 2 * iconPaddingX
|
|
7
|
+
var markerPaddings = marker ? 2 * 6 + 8 : 0; //TODO после перехода на переменные темы заменить на marker-padding-x и marker-margin-right
|
|
8
|
+
var markerWidth = ctx.measureText(marker).width + markerPaddings;
|
|
9
|
+
return containerWidth - markerWidth - 8; //TODO после перехода на переменные темы заменить на caption-margin-right
|
|
10
|
+
};
|
|
11
|
+
var getNumberOfLines = function (ctx, words, containerWidth) {
|
|
12
|
+
var line = '';
|
|
13
|
+
var lineCount = 1;
|
|
14
|
+
words.forEach(function (word, i) {
|
|
15
|
+
var testLine = (line + " " + word).trim();
|
|
16
|
+
var testWidth = ctx.measureText(testLine).width;
|
|
17
|
+
if (testWidth > containerWidth && i > 0) {
|
|
18
|
+
line = '';
|
|
19
|
+
lineCount++;
|
|
10
20
|
}
|
|
11
|
-
|
|
21
|
+
else {
|
|
22
|
+
line = testLine;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return lineCount;
|
|
26
|
+
};
|
|
27
|
+
var fontSize = size === 'small' ? 14 : 16; //TODO после перехода на переменные темы заменить на side-menu-font-size-small и side-menu-font-size-large
|
|
28
|
+
var fontFamily = textRef.current && typeof window !== undefined
|
|
29
|
+
? window.getComputedStyle(textRef.current).getPropertyValue('font-family')
|
|
30
|
+
: "'Lab Grotesque', 'Segoe UI', 'Helvetica Neue', Roboto, Arial, sans-serif";
|
|
31
|
+
var canvas = document.createElement('canvas');
|
|
32
|
+
var ctx = canvas.getContext('2d');
|
|
33
|
+
if (ctx) {
|
|
34
|
+
ctx.font = fontSize + "px " + fontFamily;
|
|
35
|
+
var words = text.split(' ');
|
|
36
|
+
setLinesNumber(getNumberOfLines(ctx, words, getContainerWidth(ctx, marker)));
|
|
12
37
|
}
|
|
13
38
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export var useNumberOfTextLinesInSubItem = function (textRef, setIsMultilineText) {
|
|
2
|
+
if (textRef.current) {
|
|
3
|
+
var el_1 = textRef.current;
|
|
4
|
+
setTimeout(function () {
|
|
5
|
+
var textHeight = +el_1.offsetHeight;
|
|
6
|
+
var lineHeight = typeof window !== undefined ? parseInt(window.getComputedStyle(el_1).getPropertyValue('line-height')) : 0;
|
|
7
|
+
var lines = textHeight / lineHeight;
|
|
8
|
+
if (lines >= 2) {
|
|
9
|
+
setIsMultilineText(true);
|
|
10
|
+
}
|
|
11
|
+
}, 0);
|
|
12
|
+
}
|
|
13
|
+
};
|
package/package.json
CHANGED
|
@@ -40,5 +40,7 @@ interface SubComponents {
|
|
|
40
40
|
SubLink: typeof SideMenuSubLink;
|
|
41
41
|
__KONTUR_REACT_UI__: string;
|
|
42
42
|
}
|
|
43
|
+
export declare const transitionDuration = 300;
|
|
44
|
+
export declare const burgerTransitionDuration: number;
|
|
43
45
|
export declare const SideMenu: React.ForwardRefExoticComponent<SideMenuProps & React.RefAttributes<HTMLElement>> & SubComponents;
|
|
44
46
|
export {};
|
package/src/SideMenu/SideMenu.js
CHANGED
|
@@ -17,12 +17,15 @@ import { RightBorder } from '../internal/RightBorder';
|
|
|
17
17
|
import { SideMenuDropdown } from '../SideMenuDropdown/SideMenuDropdown';
|
|
18
18
|
import { SideMenuLink } from '../SideMenuLink/SideMenuLink';
|
|
19
19
|
import { SideMenuSubLink } from '../SideMenuSubLink/SideMenuSubLink';
|
|
20
|
-
import { useResponsiveLayout } from '@skbkontur/react-ui';
|
|
20
|
+
import { DEFAULT_THEME, useResponsiveLayout } from '@skbkontur/react-ui';
|
|
21
21
|
import { Backdrop } from '../internal/Backdrop';
|
|
22
22
|
import { RenderLayer } from '@skbkontur/react-ui/internal/RenderLayer';
|
|
23
23
|
import { isTouchDevice } from '../../utils/scripts';
|
|
24
24
|
import { SideMenuDataTids } from '../../SideMenuDataTids';
|
|
25
25
|
import { ZIndex } from '@skbkontur/react-ui/internal/ZIndex';
|
|
26
|
+
import { useAnimateOnMount } from '../../hooks/useAnimateOnMount';
|
|
27
|
+
export var transitionDuration = 300; //ms
|
|
28
|
+
export var burgerTransitionDuration = (transitionDuration * 2) / 3;
|
|
26
29
|
var SideMenuInner = forwardRef(function (_a, ref) {
|
|
27
30
|
var _b, _c, _d, _e;
|
|
28
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.desktopMediaQuery, desktopMediaQuery = _j === void 0 ? '(min-width: 1200px)' : _j, _k = _a.narrowDesktopMediaQuery, narrowDesktopMediaQuery = _k === void 0 ? '(min-width: 992px)' : _k, _l = _a.tabletMediaQuery, tabletMediaQuery = _l === void 0 ? '(min-width: 768px)' : _l, _m = _a.mobileMediaQuery, mobileMediaQuery = _m === void 0 ? '(min-width: 0px)' : _m, _o = _a.separatedMenuWithOverlay, separatedMenuWithOverlay = _o === void 0 ? false : _o, rest = __rest(_a, ["children", "value", "onValueChange", "size", "isSeparatedMenu", "className", "disableSwipe", "desktopMediaQuery", "narrowDesktopMediaQuery", "tabletMediaQuery", "mobileMediaQuery", "separatedMenuWithOverlay"]);
|
|
@@ -53,6 +56,17 @@ var SideMenuInner = forwardRef(function (_a, ref) {
|
|
|
53
56
|
var _x = useState(true), isMouseOutside = _x[0], setIsMouseOutside = _x[1];
|
|
54
57
|
var _y = useState('top'), scrollState = _y[0], setScrollState = _y[1];
|
|
55
58
|
var _z = useState(false), hasScrollBar = _z[0], setHasScrollBar = _z[1];
|
|
59
|
+
var _0 = useState(0), mousePositionX = _0[0], setMousePositionX = _0[1];
|
|
60
|
+
useEffect(function () {
|
|
61
|
+
return function () {
|
|
62
|
+
if (transitionTimer) {
|
|
63
|
+
clearTimeout(transitionTimer);
|
|
64
|
+
}
|
|
65
|
+
if (widgetTimer) {
|
|
66
|
+
clearTimeout(widgetTimer);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}, []);
|
|
56
70
|
useEffect(function () {
|
|
57
71
|
if (isNarrowDesktop || isDesktopQuery) {
|
|
58
72
|
setIsShown(true);
|
|
@@ -83,7 +97,7 @@ var SideMenuInner = forwardRef(function (_a, ref) {
|
|
|
83
97
|
}
|
|
84
98
|
transitionTimer = setTimeout(function () {
|
|
85
99
|
setIsBeingTransitioned(false);
|
|
86
|
-
},
|
|
100
|
+
}, transitionDuration);
|
|
87
101
|
}
|
|
88
102
|
};
|
|
89
103
|
var handleMouseEnter = function () {
|
|
@@ -107,14 +121,15 @@ var SideMenuInner = forwardRef(function (_a, ref) {
|
|
|
107
121
|
setIsMouseOutside(true);
|
|
108
122
|
};
|
|
109
123
|
var showMinimizedRootForNarrowDesktopWithOverlay = function (e) {
|
|
110
|
-
if (separatedMenuWithoutOverlay
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
124
|
+
if (!separatedMenuWithoutOverlay || !isNarrowDesktop)
|
|
125
|
+
return;
|
|
126
|
+
if (e.clientX < parseInt(sideMenuMinimizedWidth) && mousePositionX > parseInt(sideMenuMinimizedWidth)) {
|
|
127
|
+
showMinimizedRoot(false);
|
|
128
|
+
}
|
|
129
|
+
if (e.clientX > parseInt(sideMenuStandardWidth)) {
|
|
130
|
+
showMinimizedRoot(true);
|
|
117
131
|
}
|
|
132
|
+
setMousePositionX(e.clientX);
|
|
118
133
|
};
|
|
119
134
|
var switchActiveMenuItem = function (id) {
|
|
120
135
|
if (id !== value) {
|
|
@@ -122,13 +137,26 @@ var SideMenuInner = forwardRef(function (_a, ref) {
|
|
|
122
137
|
setActiveMenuItem(id);
|
|
123
138
|
}
|
|
124
139
|
};
|
|
125
|
-
var
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
140
|
+
var handleIsShown = function (newIsShown) {
|
|
141
|
+
if (!isTabletOrMobile)
|
|
142
|
+
return;
|
|
143
|
+
if (!isBeingTransitioned && newIsShown !== isShown) {
|
|
144
|
+
setIsBeingTransitioned(true);
|
|
145
|
+
setIsShown(newIsShown);
|
|
146
|
+
if (transitionTimer) {
|
|
147
|
+
clearTimeout(transitionTimer);
|
|
148
|
+
}
|
|
149
|
+
transitionTimer = setTimeout(function () {
|
|
150
|
+
setIsBeingTransitioned(false);
|
|
151
|
+
}, burgerTransitionDuration);
|
|
152
|
+
}
|
|
130
153
|
};
|
|
131
154
|
var isSideMenuOverContent = (isNarrowDesktop && !isMinimized) || (isMobile && isShown) || (isTablet && isShown && !isSeparatedMenuShown);
|
|
155
|
+
var _1 = useAnimateOnMount(!!isTabletOrMobile && !!isShown, burgerTransitionDuration, {
|
|
156
|
+
opacity: DEFAULT_THEME.sidePageBackingBgOpacity,
|
|
157
|
+
}, {
|
|
158
|
+
opacity: 0,
|
|
159
|
+
}), shouldShowBackdrop = _1[0], backdropStyle = _1[1];
|
|
132
160
|
return (React.createElement(SideMenuContext.Provider, { value: {
|
|
133
161
|
isMinimized: isMinimized,
|
|
134
162
|
setIsMinimized: showMinimizedRoot,
|
|
@@ -146,7 +174,7 @@ var SideMenuInner = forwardRef(function (_a, ref) {
|
|
|
146
174
|
isMobile: isMobile,
|
|
147
175
|
isTouchScreen: isTouchScreen,
|
|
148
176
|
isShown: isShown,
|
|
149
|
-
toggleIsShown:
|
|
177
|
+
toggleIsShown: function () { return handleIsShown(!isShown); },
|
|
150
178
|
isSeparatedMenuShown: isSeparatedMenuShown,
|
|
151
179
|
setIsSeparatedMenuShown: setIsSeparatedMenuShown,
|
|
152
180
|
separatedMenuWithoutOverlay: separatedMenuWithoutOverlay,
|
|
@@ -165,8 +193,8 @@ var SideMenuInner = forwardRef(function (_a, ref) {
|
|
|
165
193
|
_b[jsStyles.separatedRootForDesktops()] = separatedMenuWithoutOverlay && isSeparatedMenuShown && isDesktopQuery,
|
|
166
194
|
_b)) },
|
|
167
195
|
React.createElement(React.Fragment, null,
|
|
168
|
-
|
|
169
|
-
React.createElement(RenderLayer, { onClickOutside:
|
|
196
|
+
shouldShowBackdrop && React.createElement(Backdrop, { style: backdropStyle }),
|
|
197
|
+
React.createElement(RenderLayer, { onClickOutside: function () { return handleIsShown(false); } },
|
|
170
198
|
React.createElement("aside", __assign({ className: cx((_c = {},
|
|
171
199
|
_c[jsStyles.wrapper()] = true,
|
|
172
200
|
_c[jsStyles.wrapperIE()] = isIE11,
|
|
@@ -174,15 +202,14 @@ var SideMenuInner = forwardRef(function (_a, ref) {
|
|
|
174
202
|
_c), className), "data-tid": SideMenuDataTids.root, ref: ref }, rest, { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onMouseMove: showMinimizedRootForNarrowDesktopWithOverlay }),
|
|
175
203
|
React.createElement("div", { className: cx((_d = {},
|
|
176
204
|
_d[jsStyles.container()] = true,
|
|
177
|
-
_d[jsStyles.collapsedContainerForTabletsOrMobiles()] = !isShown,
|
|
205
|
+
_d[jsStyles.collapsedContainerForTabletsOrMobiles()] = !isShown && !isBeingTransitioned,
|
|
178
206
|
_d[jsStyles.minimizedContainer()] = isMinimized,
|
|
179
207
|
_d[jsStyles.innerContainer()] = !isSeparatedMenu,
|
|
180
208
|
_d[jsStyles.containerForTouchScreens()] = isTouchScreen,
|
|
181
|
-
_d[jsStyles.separatedContainerForMobiles()] = isMobile && isSeparatedMenuShown && isShown,
|
|
209
|
+
_d[jsStyles.separatedContainerForMobiles()] = isMobile && isSeparatedMenuShown && (isShown || isBeingTransitioned),
|
|
182
210
|
_d)) },
|
|
183
211
|
React.createElement("div", { className: cx((_e = {},
|
|
184
212
|
_e[jsStyles.contentWrapper()] = true,
|
|
185
|
-
_e[jsStyles.collapsedContentWrapperForTabletsOrMobiles()] = !isShown || isSeparatedMenuShown,
|
|
186
213
|
_e)) }, children)),
|
|
187
214
|
!disableSwipe && isDesktopQuery && !isSeparatedMenuShown && (React.createElement(RightBorder, { setIsMinimized: setIsMinimized }))))))));
|
|
188
215
|
});
|
|
@@ -11,7 +11,6 @@ export declare const jsStyles: {
|
|
|
11
11
|
separatedRootForNarrowDesktops(): string;
|
|
12
12
|
separatedRootForDesktops(): string;
|
|
13
13
|
container(): string;
|
|
14
|
-
collapsedContentWrapperForTabletsOrMobiles(): string;
|
|
15
14
|
minimizedContainer(): string;
|
|
16
15
|
innerContainer(): string;
|
|
17
16
|
containerForTouchScreens(): string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __makeTemplateObject } from "tslib";
|
|
2
2
|
import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
import { burgerTransitionDuration, transitionDuration } from './SideMenu';
|
|
3
4
|
export var sideMenuMinimizedWidth = '72px';
|
|
4
5
|
export var sideMenuStandardWidth = '232px';
|
|
5
6
|
export var sideMenuForTouchScreenWidth = '328px';
|
|
@@ -10,10 +11,10 @@ var styles = {
|
|
|
10
11
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n height: 100%;\n flex-shrink: 0;\n "], ["\n position: relative;\n height: 100%;\n flex-shrink: 0;\n "])));
|
|
11
12
|
},
|
|
12
13
|
rootForTabletsOrMobiles: function () {
|
|
13
|
-
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n height: 68px;\n position: absolute;\n top: 0;\n "], ["\n height: 68px;\n position: absolute;\n top: 0;\n "])));
|
|
14
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n height: 68px;\n position: absolute;\n top: 0;\n transition: height ", "ms ease-out;\n "], ["\n height: 68px;\n position: absolute;\n top: 0;\n transition: height ", "ms ease-out;\n "])), burgerTransitionDuration);
|
|
14
15
|
},
|
|
15
16
|
shownRootForTabletsOrMobiles: function () {
|
|
16
|
-
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n height: 100vh;\n "], ["\n height: 100vh;\n "])));
|
|
17
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n height: 100vh;\n transition: height ", "ms ease-out;\n "], ["\n height: 100vh;\n transition: height ", "ms ease-out;\n "])), burgerTransitionDuration);
|
|
17
18
|
},
|
|
18
19
|
rootForNarrowDesktops: function () {
|
|
19
20
|
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: ", ";\n "], ["\n width: ", ";\n "])), sideMenuMinimizedWidth);
|
|
@@ -25,39 +26,36 @@ var styles = {
|
|
|
25
26
|
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n width: calc(", " + ", ");\n background: #fff;\n "], ["\n width: calc(", " + ", ");\n background: #fff;\n "])), sideMenuStandardWidth, sideMenuStandardWidth);
|
|
26
27
|
},
|
|
27
28
|
container: function () {
|
|
28
|
-
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n width: ", ";\n height: 100%;\n background: #f6f6f6;\n position: relative;\n box-sizing: border-box;\n transition: width
|
|
29
|
-
},
|
|
30
|
-
collapsedContentWrapperForTabletsOrMobiles: function () {
|
|
31
|
-
return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n overflow: hidden;\n "], ["\n overflow: hidden;\n "])));
|
|
29
|
+
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n width: ", ";\n height: 100%;\n background: #f6f6f6;\n position: relative;\n box-sizing: border-box;\n transition: width ", "ms ease-out;\n "], ["\n width: ", ";\n height: 100%;\n background: #f6f6f6;\n position: relative;\n box-sizing: border-box;\n transition: width ", "ms ease-out;\n "])), sideMenuStandardWidth, transitionDuration);
|
|
32
30
|
},
|
|
33
31
|
minimizedContainer: function () {
|
|
34
|
-
return css(
|
|
32
|
+
return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n width: ", " !important;\n "], ["\n width: ", " !important;\n "])), sideMenuMinimizedWidth);
|
|
35
33
|
},
|
|
36
34
|
innerContainer: function () {
|
|
37
|
-
return css(
|
|
35
|
+
return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n overflow-x: hidden;\n "], ["\n overflow-x: hidden;\n "])));
|
|
38
36
|
},
|
|
39
37
|
containerForTouchScreens: function () {
|
|
40
|
-
return css(
|
|
38
|
+
return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n width: ", ";\n "], ["\n width: ", ";\n "])), sideMenuForTouchScreenWidth);
|
|
41
39
|
},
|
|
42
40
|
separatedContainerForMobiles: function () {
|
|
43
|
-
return css(
|
|
41
|
+
return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n background: #fff;\n "], ["\n background: #fff;\n "])));
|
|
44
42
|
},
|
|
45
43
|
contentWrapper: function () {
|
|
46
|
-
return css(
|
|
44
|
+
return css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n height: 100%;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n overflow: hidden;\n "], ["\n height: 100%;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n overflow: hidden;\n "])));
|
|
47
45
|
},
|
|
48
46
|
wrapper: function () {
|
|
49
|
-
return css(
|
|
47
|
+
return css(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n height: 100%;\n display: inline-flex;\n position: relative;\n "], ["\n height: 100%;\n display: inline-flex;\n position: relative;\n "])));
|
|
50
48
|
},
|
|
51
49
|
wrapperIE: function () {
|
|
52
50
|
var ieRootWrapperCorrection = 15;
|
|
53
|
-
return css(
|
|
51
|
+
return css(templateObject_14 || (templateObject_14 = __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);
|
|
54
52
|
},
|
|
55
53
|
wrapperWithShadow: function () {
|
|
56
|
-
return css(
|
|
54
|
+
return css(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n box-shadow: ", ";\n "], ["\n box-shadow: ", ";\n "])), sideMenuBoxShadow);
|
|
57
55
|
},
|
|
58
56
|
collapsedContainerForTabletsOrMobiles: function () {
|
|
59
|
-
return css(
|
|
57
|
+
return css(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n background-color: transparent;\n "], ["\n background-color: transparent;\n "])));
|
|
60
58
|
},
|
|
61
59
|
};
|
|
62
60
|
export var jsStyles = memoizeStyle(styles);
|
|
63
|
-
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, templateObject_15, templateObject_16
|
|
61
|
+
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, templateObject_15, templateObject_16;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { __makeTemplateObject } from "tslib";
|
|
2
2
|
import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
import { transitionDuration } from '../SideMenu/SideMenu';
|
|
3
4
|
var styles = {
|
|
4
5
|
label: function () {
|
|
5
|
-
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 200px;\n transition: width
|
|
6
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 200px;\n transition: width ", "ms ease-out;\n "], ["\n width: 200px;\n transition: width ", "ms ease-out;\n "])), transitionDuration);
|
|
6
7
|
},
|
|
7
8
|
minimizedLabel: function () {
|
|
8
9
|
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: 100%;\n "], ["\n width: 100%;\n "])));
|
|
@@ -13,7 +13,11 @@ var SideMenuFooterInner = forwardRef(function (_a, ref) {
|
|
|
13
13
|
setIsFixed(!!context.hasScrollBar && !(context.scrollState === 'bottom'));
|
|
14
14
|
}, [context.hasScrollBar, context.scrollState]);
|
|
15
15
|
if (context.isShown) {
|
|
16
|
-
return (React.createElement("footer", __assign({ className: cx((_b = {},
|
|
16
|
+
return (React.createElement("footer", __assign({ className: cx((_b = {},
|
|
17
|
+
_b[jsStyles.root()] = true,
|
|
18
|
+
_b[jsStyles.rootFixed()] = isFixed,
|
|
19
|
+
_b[jsStyles.rootTransitioned()] = context.isBeingTransitioned,
|
|
20
|
+
_b), className), ref: ref }, rest), React.Children.map(children, function (child, index) {
|
|
17
21
|
if (React.isValidElement(child)) {
|
|
18
22
|
return React.cloneElement(child, {
|
|
19
23
|
_generatedId: getItemId('footer', index++),
|
|
@@ -8,6 +8,9 @@ var styles = {
|
|
|
8
8
|
rootFixed: function () {
|
|
9
9
|
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n box-shadow: inset 0 1px 0 #e6e6e6;\n "], ["\n box-shadow: inset 0 1px 0 #e6e6e6;\n "])));
|
|
10
10
|
},
|
|
11
|
+
rootTransitioned: function () {
|
|
12
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: static;\n "], ["\n position: static;\n "])));
|
|
13
|
+
},
|
|
11
14
|
};
|
|
12
15
|
export var jsStyles = memoizeStyle(styles);
|
|
13
|
-
var templateObject_1, templateObject_2;
|
|
16
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -12,9 +12,10 @@ var SideMenuHeaderInner = forwardRef(function (_a, ref) {
|
|
|
12
12
|
var headerWrapperRef = useRef(null);
|
|
13
13
|
return (React.createElement("header", __assign({ className: cx((_b = {},
|
|
14
14
|
_b[jsStyles.root()] = true,
|
|
15
|
+
_b[jsStyles.rootForTabletsOrMobiles()] = context.isMobile || context.isTablet,
|
|
15
16
|
_b[jsStyles.fixedRoot()] = context.isShown && !(context.scrollState === 'top'),
|
|
16
17
|
_b[jsStyles.minimizedRoot()] = context.isMinimized || context.isBeingTransitioned,
|
|
17
|
-
_b[jsStyles.collapsedRootForTabletsOrMobiles()] = !context.isShown,
|
|
18
|
+
_b[jsStyles.collapsedRootForTabletsOrMobiles()] = !context.isShown || context.isBeingTransitioned,
|
|
18
19
|
_b[jsStyles.rootWithSeparatedMenuShown()] = context.isShown && context.isMobile && context.isSeparatedMenuShown,
|
|
19
20
|
_b), className), ref: mergeRefs([headerWrapperRef, ref]), style: style }, rest),
|
|
20
21
|
React.createElement(SideMenuLogotype, __assign({ productLogo: productLogo, konturLogo: konturLogo, iconUrl: iconUrl, withWidget: withWidget }, rest))));
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { __makeTemplateObject } from "tslib";
|
|
2
2
|
import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
3
|
import { sideMenuMarginX } from '../SideMenu/SideMenu.styles';
|
|
4
|
-
var headerWrapperPaddingX = '8px';
|
|
5
4
|
var styles = {
|
|
6
5
|
root: function () {
|
|
7
|
-
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: sticky;\n width: calc(100% - 2 * ", "
|
|
6
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: sticky;\n width: calc(100% - 2 * ", ");\n top: 0;\n z-index: 1;\n padding: 24px 0 8px;\n margin: 0 ", ";\n "], ["\n position: sticky;\n width: calc(100% - 2 * ", ");\n top: 0;\n z-index: 1;\n padding: 24px 0 8px;\n margin: 0 ", ";\n "])), sideMenuMarginX, sideMenuMarginX);
|
|
8
7
|
},
|
|
9
8
|
minimizedRoot: function () {
|
|
10
|
-
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: 54px;\n
|
|
9
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: 54px;\n "], ["\n width: 54px;\n "])));
|
|
10
|
+
},
|
|
11
|
+
rootForTabletsOrMobiles: function () {
|
|
12
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding-top: 16px;\n "], ["\n padding-top: 16px;\n "])));
|
|
11
13
|
},
|
|
12
14
|
collapsedRootForTabletsOrMobiles: function () {
|
|
13
|
-
return css(
|
|
15
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n background: transparent;\n "], ["\n background: transparent;\n "])));
|
|
14
16
|
},
|
|
15
17
|
rootWithSeparatedMenuShown: function () {
|
|
16
|
-
return css(
|
|
18
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n background: #fff;\n "], ["\n background: #fff;\n "])));
|
|
17
19
|
},
|
|
18
20
|
fixedRoot: function () {
|
|
19
|
-
return css(
|
|
21
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding-bottom: 8px;\n box-shadow: inset 0 -1px 0 #e6e6e6;\n "], ["\n padding-bottom: 8px;\n box-shadow: inset 0 -1px 0 #e6e6e6;\n "])));
|
|
20
22
|
},
|
|
21
23
|
};
|
|
22
24
|
export var jsStyles = memoizeStyle(styles);
|
|
23
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
25
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
|
package/src/internal/Backdrop.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { HideBodyVerticalScroll } from '@skbkontur/react-ui/internal/HideBodyVerticalScroll';
|
|
3
4
|
import { jsStyles } from './Backdrop.styles';
|
|
4
5
|
import { DEFAULT_THEME } from '@skbkontur/react-ui';
|
|
5
6
|
import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
6
|
-
export var Backdrop = function () {
|
|
7
|
+
export var Backdrop = function (props) {
|
|
7
8
|
var _a;
|
|
8
9
|
return (React.createElement("div", { className: cx((_a = {},
|
|
9
10
|
_a[jsStyles.rootForTabletsOrMobiles()] = true,
|
|
10
|
-
_a)), style: {
|
|
11
|
-
background: DEFAULT_THEME.sidePageBackingBg,
|
|
12
|
-
opacity: DEFAULT_THEME.sidePageBackingBgOpacity,
|
|
13
|
-
} },
|
|
11
|
+
_a)), style: __assign({ background: DEFAULT_THEME.sidePageBackingBg }, props.style) },
|
|
14
12
|
React.createElement(HideBodyVerticalScroll, null)));
|
|
15
13
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { __makeTemplateObject } from "tslib";
|
|
2
2
|
import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
import { burgerTransitionDuration } from '../SideMenu/SideMenu';
|
|
3
4
|
var styles = {
|
|
4
5
|
rootForTabletsOrMobiles: function () {
|
|
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
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n transition: opacity ", "ms ease-in;\n "], ["\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n transition: opacity ", "ms ease-in;\n "])), burgerTransitionDuration);
|
|
6
7
|
},
|
|
7
8
|
};
|
|
8
9
|
export var jsStyles = memoizeStyle(styles);
|
|
@@ -2,7 +2,7 @@ import { __makeTemplateObject } from "tslib";
|
|
|
2
2
|
import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
3
|
var styles = {
|
|
4
4
|
root: function () {
|
|
5
|
-
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border: none;\n margin: 0;\n padding: 0;\n overflow: visible;\n color: inherit;\n font: inherit;\n line-height: normal;\n text-align: inherit;\n outline: none;\n width: 100%;\n background:
|
|
5
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border: none;\n margin: 0;\n padding: 0;\n overflow: visible;\n color: inherit;\n font: inherit;\n line-height: normal;\n text-align: inherit;\n outline: none;\n width: 100%;\n background: transparent;\n border-radius: 8px;\n box-sizing: border-box;\n cursor: pointer;\n &:hover {\n background: rgba(255, 255, 255, 0.48);\n }\n &:focus {\n outline: none;\n }\n "], ["\n border: none;\n margin: 0;\n padding: 0;\n overflow: visible;\n color: inherit;\n font: inherit;\n line-height: normal;\n text-align: inherit;\n outline: none;\n width: 100%;\n background: transparent;\n border-radius: 8px;\n box-sizing: border-box;\n cursor: pointer;\n &:hover {\n background: rgba(255, 255, 255, 0.48);\n }\n &:focus {\n outline: none;\n }\n "])));
|
|
6
6
|
},
|
|
7
7
|
rootSubItem: function () {
|
|
8
8
|
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background: #fff;\n &:hover {\n background: #f6f6f6;\n }\n "], ["\n background: #fff;\n &:hover {\n background: #f6f6f6;\n }\n "])));
|
|
@@ -9,14 +9,14 @@ export var Caption = forwardRef(function (_a, ref) {
|
|
|
9
9
|
var isBeingTransitioned = context.isBeingTransitioned, isSeparatedMenu = context.isSeparatedMenu, size = context.size, isTouchScreen = context.isTouchScreen, hasSubIcons = context.hasSubIcons;
|
|
10
10
|
return (React.createElement("p", { className: cx((_b = {},
|
|
11
11
|
_b[jsStyles.root()] = true,
|
|
12
|
-
_b[jsStyles.rootBeingTransitioned()] = isBeingTransitioned && !_isSubMenu,
|
|
12
|
+
_b[jsStyles.rootBeingTransitioned()] = isBeingTransitioned && !_isSubMenu && !(context.isTablet || context.isMobile),
|
|
13
13
|
_b[jsStyles.rootSubItem()] = _isSubMenu,
|
|
14
14
|
_b[jsStyles.rootSubItemSeparatedMenuTopLevel()] = isSeparatedMenu && !_isNestedSubMenu && _isSubMenu,
|
|
15
15
|
_b[jsStyles.rootNestedItemSeparatedMenu()] = isSeparatedMenu && _isNestedSubMenu && !hasShortcutImage,
|
|
16
16
|
_b[jsStyles.rootWithoutItemIcon()] = !hasShortcutImage && !isSeparatedMenu,
|
|
17
17
|
_b[jsStyles.rootSubItemWithoutColumnIcons()] = _isSubMenu && isSeparatedMenu && !hasSubIcons,
|
|
18
18
|
_b[jsStyles.rootLarge()] = size === 'large',
|
|
19
|
-
_b[jsStyles.rootMultiline()] = isMultiline,
|
|
19
|
+
_b[jsStyles.rootMultiline()] = isMultiline && !_isSubMenu,
|
|
20
20
|
_b[jsStyles.rootForTouchScreens()] = isTouchScreen,
|
|
21
21
|
_b[jsStyles.rootSubItemForTouchScreens()] = isTouchScreen && _isSubMenu,
|
|
22
22
|
_b[jsStyles.rootInBackButton()] = _isBackButton,
|
|
@@ -8,7 +8,7 @@ var styles = {
|
|
|
8
8
|
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n white-space: nowrap;\n overflow-x: hidden;\n text-overflow: ellipsis;\n "], ["\n white-space: nowrap;\n overflow-x: hidden;\n text-overflow: ellipsis;\n "])));
|
|
9
9
|
},
|
|
10
10
|
rootMultiline: function () {
|
|
11
|
-
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n align-self: flex-start;\n "], ["\n align-self: flex-start;\n "])));
|
|
11
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding-top: 4px;\n align-self: flex-start;\n "], ["\n padding-top: 4px;\n align-self: flex-start;\n "])));
|
|
12
12
|
},
|
|
13
13
|
rootForTouchScreens: function () {
|
|
14
14
|
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-size: 18px;\n line-height: 24px;\n "], ["\n font-size: 18px;\n line-height: 24px;\n "])));
|
|
@@ -14,9 +14,8 @@ export var Icon = function (_a) {
|
|
|
14
14
|
disableCompensation: !_isBackButton,
|
|
15
15
|
className: cx((_b = {},
|
|
16
16
|
_b[jsStyles.root()] = true,
|
|
17
|
-
_b[jsStyles.rootMultiline()] = isMultiline && !context.isMinimized,
|
|
17
|
+
_b[jsStyles.rootMultiline()] = isMultiline && (!context.isMinimized || _isSubMenu),
|
|
18
18
|
_b[jsStyles.rootLarge()] = size === 'large',
|
|
19
|
-
_b[jsStyles.rootMultilineLarge()] = size === 'large' && isMultiline,
|
|
20
19
|
_b[jsStyles.rootSubItem()] = _isSubMenu,
|
|
21
20
|
_b[jsStyles.rootSubItemSeparatedMenu()] = isSeparatedMenu && _isSubMenu,
|
|
22
21
|
_b[jsStyles.rootSubItemLarge()] = _isSubMenu && size === 'large',
|
|
@@ -5,26 +5,23 @@ var styles = {
|
|
|
5
5
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n padding: 0 8px;\n min-height: 32px;\n line-height: 20px;\n flex-shrink: 0;\n "], ["\n display: flex;\n align-items: center;\n padding: 0 8px;\n min-height: 32px;\n line-height: 20px;\n flex-shrink: 0;\n "])));
|
|
6
6
|
},
|
|
7
7
|
rootMultiline: function () {
|
|
8
|
-
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n
|
|
8
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n align-self: flex-start;\n align-items: flex-start;\n "], ["\n align-self: flex-start;\n align-items: flex-start;\n "])));
|
|
9
9
|
},
|
|
10
10
|
rootLarge: function () {
|
|
11
11
|
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n min-height: 30px;\n line-height: 22px;\n "], ["\n min-height: 30px;\n line-height: 22px;\n "])));
|
|
12
12
|
},
|
|
13
|
-
rootMultilineLarge: function () {
|
|
14
|
-
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n min-height: 0;\n "], ["\n min-height: 0;\n "])));
|
|
15
|
-
},
|
|
16
13
|
rootSubItemLarge: function () {
|
|
17
|
-
return css(
|
|
14
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n min-height: 22px;\n "], ["\n min-height: 22px;\n "])));
|
|
18
15
|
},
|
|
19
16
|
rootSubItem: function () {
|
|
20
|
-
return css(
|
|
17
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n padding-left: 20px;\n padding-right: 0;\n min-height: 20px;\n line-height: 16px;\n "], ["\n padding-left: 20px;\n padding-right: 0;\n min-height: 20px;\n line-height: 16px;\n "])));
|
|
21
18
|
},
|
|
22
19
|
rootSubItemSeparatedMenu: function () {
|
|
23
|
-
return css(
|
|
20
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding-left: 4px;\n "], ["\n padding-left: 4px;\n "])));
|
|
24
21
|
},
|
|
25
22
|
rootBackButton: function () {
|
|
26
|
-
return css(
|
|
23
|
+
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n padding-left: 10px;\n padding-right: 6px;\n "], ["\n padding-left: 10px;\n padding-right: 6px;\n "])));
|
|
27
24
|
},
|
|
28
25
|
};
|
|
29
26
|
export var jsStyles = memoizeStyle(styles);
|
|
30
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7
|
|
27
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React, { forwardRef, useContext, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
-
import { jsStyles } from './ItemContent.styles';
|
|
3
|
+
import { customStyles, jsStyles } from './ItemContent.styles';
|
|
4
4
|
import { SideMenuContext } from '../../SideMenuContext';
|
|
5
5
|
import { useNumberOfTextLinesInItem } from '../../../hooks/useNumberOfTextLinesInItem';
|
|
6
|
+
import { useNumberOfTextLinesInSubItem } from '../../../hooks/useNumberOfTextLinesInSubItem';
|
|
6
7
|
import { Icon } from './Icon';
|
|
7
8
|
import { Caption } from './Caption';
|
|
8
9
|
import { Marker } from './Marker';
|
|
@@ -11,18 +12,30 @@ import { Avatar } from './Avatar';
|
|
|
11
12
|
* Контент для SideMenuItem или SideMenuLink
|
|
12
13
|
*/
|
|
13
14
|
var ItemContent = forwardRef(function (_a, ref) {
|
|
14
|
-
var _b;
|
|
15
|
+
var _b, _c;
|
|
15
16
|
var _isSubMenu = _a._isSubMenu, icon = _a.icon, _isNestedSubMenu = _a._isNestedSubMenu, caption = _a.caption, marker = _a.marker, _avatar = _a._avatar, _isBackButton = _a._isBackButton;
|
|
16
17
|
var context = useContext(SideMenuContext);
|
|
17
18
|
var textRef = useRef(null);
|
|
18
|
-
var
|
|
19
|
+
var _d = useState(1), linesNumber = _d[0], setLinesNumber = _d[1];
|
|
20
|
+
var _e = useState(false), isMultilineSubItem = _e[0], setMultilineSubItem = _e[1];
|
|
21
|
+
var isMultiline = (!_isSubMenu && linesNumber > 1) || (!!_isSubMenu && isMultilineSubItem);
|
|
19
22
|
useEffect(function () {
|
|
20
|
-
!_isBackButton &&
|
|
23
|
+
if (!_isBackButton && !_isSubMenu) {
|
|
24
|
+
useNumberOfTextLinesInItem(textRef, setLinesNumber, caption, marker, context.size);
|
|
25
|
+
}
|
|
26
|
+
if (!_isBackButton && _isSubMenu) {
|
|
27
|
+
useNumberOfTextLinesInSubItem(textRef, setMultilineSubItem);
|
|
28
|
+
}
|
|
29
|
+
}, []);
|
|
30
|
+
useEffect(function () {
|
|
31
|
+
if (!_isBackButton) {
|
|
32
|
+
useNumberOfTextLinesInItem(textRef, setLinesNumber, caption, marker, context.size);
|
|
33
|
+
}
|
|
21
34
|
}, [textRef.current, context.isBeingTransitioned]);
|
|
22
35
|
var hasShortcutImage = !!icon || !!_avatar;
|
|
36
|
+
var isSeparatedSubMenuInNarrowDesktopWithoutOverlay = _isSubMenu && context.separatedMenuWithoutOverlay && context.isNarrowDesktop;
|
|
23
37
|
return (React.createElement("div", { className: cx((_b = {},
|
|
24
38
|
_b[jsStyles.root()] = true,
|
|
25
|
-
_b[jsStyles.multilineRoot()] = isMultiline,
|
|
26
39
|
_b[jsStyles.subItemRoot()] = _isSubMenu,
|
|
27
40
|
_b[jsStyles.largeRoot()] = context.size === 'large',
|
|
28
41
|
_b[jsStyles.subItemLargeRoot()] = context.size === 'large' && _isSubMenu,
|
|
@@ -32,9 +45,13 @@ var ItemContent = forwardRef(function (_a, ref) {
|
|
|
32
45
|
_b)), ref: ref },
|
|
33
46
|
icon && React.createElement(Icon, { icon: icon, _isSubMenu: _isSubMenu, isMultiline: isMultiline, _isBackButton: _isBackButton }),
|
|
34
47
|
_avatar && React.createElement(Avatar, { _avatar: _avatar }),
|
|
35
|
-
(!context.isMinimized || (context.isMinimized && _isSubMenu)) && (React.createElement("div", { className:
|
|
48
|
+
(!context.isMinimized || (context.isMinimized && _isSubMenu)) && (React.createElement("div", { className: cx((_c = {},
|
|
49
|
+
_c[jsStyles.textAndMarkerWrapper()] = true,
|
|
50
|
+
_c[customStyles.textAndMarkerWrapperMultiline(linesNumber)] = isMultiline && !_isSubMenu,
|
|
51
|
+
_c[customStyles.largeTextAndMarkerWrapperMultiline(linesNumber)] = isMultiline && context.size === 'large' && !_isSubMenu,
|
|
52
|
+
_c)) },
|
|
36
53
|
React.createElement(Caption, { _isSubMenu: _isSubMenu, _isNestedSubMenu: _isNestedSubMenu, hasShortcutImage: hasShortcutImage, isMultiline: isMultiline, caption: caption, _isBackButton: _isBackButton, ref: textRef }),
|
|
37
|
-
marker && React.createElement(Marker, { isMultiline: isMultiline, marker: marker })))));
|
|
54
|
+
marker && (!context.isMinimized || isSeparatedSubMenuInNarrowDesktopWithoutOverlay) && (React.createElement(Marker, { isMultiline: isMultiline, marker: marker }))))));
|
|
38
55
|
});
|
|
39
56
|
ItemContent.displayName = 'ItemContent';
|
|
40
57
|
var ItemContentWithStaticFields = Object.assign(ItemContent, { __KONTUR_REACT_UI__: 'ItemContent' });
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
export declare const customStyles: {
|
|
2
|
+
textAndMarkerWrapperMultiline(linesNumber: number): string;
|
|
3
|
+
largeTextAndMarkerWrapperMultiline(linesNumber: number): string;
|
|
4
|
+
};
|
|
1
5
|
export declare const jsStyles: {
|
|
2
6
|
root(): string;
|
|
3
|
-
multilineRoot(): string;
|
|
4
7
|
largeRoot(): string;
|
|
5
8
|
subItemLargeRoot(): string;
|
|
6
9
|
largeMultilineRoot(): string;
|
|
@@ -4,30 +4,37 @@ var styles = {
|
|
|
4
4
|
root: function () {
|
|
5
5
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n padding-top: 4px;\n padding-bottom: 4px;\n "], ["\n display: flex;\n align-items: center;\n padding-top: 4px;\n padding-bottom: 4px;\n "])));
|
|
6
6
|
},
|
|
7
|
-
multilineRoot: function () {
|
|
8
|
-
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding-top: 8px;\n padding-bottom: 8px;\n "], ["\n padding-top: 8px;\n padding-bottom: 8px;\n "])));
|
|
9
|
-
},
|
|
10
7
|
largeRoot: function () {
|
|
11
|
-
return css(
|
|
8
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding-top: 9px !important;\n padding-bottom: 9px !important;\n "], ["\n padding-top: 9px !important;\n padding-bottom: 9px !important;\n "])));
|
|
12
9
|
},
|
|
13
10
|
subItemLargeRoot: function () {
|
|
14
|
-
return css(
|
|
11
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding-top: 5px !important;\n padding-bottom: 5px !important;\n "], ["\n padding-top: 5px !important;\n padding-bottom: 5px !important;\n "])));
|
|
15
12
|
},
|
|
16
13
|
largeMultilineRoot: function () {
|
|
17
|
-
return css(
|
|
14
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n padding-top: 8px;\n padding-bottom: 8px;\n "], ["\n padding-top: 8px;\n padding-bottom: 8px;\n "])));
|
|
18
15
|
},
|
|
19
16
|
rootForTouchScreens: function () {
|
|
20
|
-
return css(
|
|
17
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n padding-top: 8px;\n padding-bottom: 8px;\n "], ["\n padding-top: 8px;\n padding-bottom: 8px;\n "])));
|
|
21
18
|
},
|
|
22
19
|
subItemRootForTouchScreens: function () {
|
|
23
|
-
return css(
|
|
20
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding-top: 9px;\n padding-bottom: 9px;\n "], ["\n padding-top: 9px;\n padding-bottom: 9px;\n "])));
|
|
24
21
|
},
|
|
25
22
|
subItemRoot: function () {
|
|
26
|
-
return css(
|
|
23
|
+
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n padding-top: 4px;\n padding-bottom: 4px;\n "], ["\n padding-top: 4px;\n padding-bottom: 4px;\n "])));
|
|
27
24
|
},
|
|
28
25
|
textAndMarkerWrapper: function () {
|
|
29
|
-
return css(
|
|
26
|
+
return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n display: flex;\n flex-grow: 1;\n align-items: center;\n "], ["\n display: flex;\n flex-grow: 1;\n align-items: center;\n "])));
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
export var customStyles = {
|
|
30
|
+
textAndMarkerWrapperMultiline: function (linesNumber) {
|
|
31
|
+
var height = linesNumber * 20 + 4; // TODO: после перехода на переменные темы заменить на формулу: linesNumber*line-height + caption-multiline-padding-top
|
|
32
|
+
return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n min-height: ", "px;\n "], ["\n min-height: ", "px;\n "])), height);
|
|
33
|
+
},
|
|
34
|
+
largeTextAndMarkerWrapperMultiline: function (linesNumber) {
|
|
35
|
+
var height = linesNumber * 22 + 4; // TODO: после перехода на переменные темы заменить на формулу: linesNumber*line-height-large + caption-multiline-padding-top
|
|
36
|
+
return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n min-height: ", "px;\n "], ["\n min-height: ", "px;\n "])), height);
|
|
30
37
|
},
|
|
31
38
|
};
|
|
32
39
|
export var jsStyles = memoizeStyle(styles);
|
|
33
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9;
|
|
40
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
|
|
@@ -5,7 +5,7 @@ var styles = {
|
|
|
5
5
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding-right: 6px;\n padding-left: 6px;\n background: #2291ff;\n border-radius: 9999px;\n margin-left: auto;\n margin-right: 8px;\n color: #fff;\n line-height: 20px;\n font-weight: 700;\n "], ["\n padding-right: 6px;\n padding-left: 6px;\n background: #2291ff;\n border-radius: 9999px;\n margin-left: auto;\n margin-right: 8px;\n color: #fff;\n line-height: 20px;\n font-weight: 700;\n "])));
|
|
6
6
|
},
|
|
7
7
|
rootMultiline: function () {
|
|
8
|
-
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n align-self: flex-start;\n "], ["\n align-self: flex-start;\n "])));
|
|
8
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n align-self: flex-start;\n margin-top: 4px;\n "], ["\n align-self: flex-start;\n margin-top: 4px;\n "])));
|
|
9
9
|
},
|
|
10
10
|
};
|
|
11
11
|
export var jsStyles = memoizeStyle(styles);
|
|
@@ -4,16 +4,18 @@ import { Logotype } from '@skbkontur/react-ui-addons/components/Logotype';
|
|
|
4
4
|
import { jsStyles } from './SideMenuLogotype.styles';
|
|
5
5
|
import { SideMenuContext } from '../SideMenuContext';
|
|
6
6
|
import { Burger } from './Burger';
|
|
7
|
+
import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
7
8
|
/**
|
|
8
9
|
* Логотип
|
|
9
10
|
*
|
|
10
11
|
* @visibleName SideMenu.Logotype
|
|
11
12
|
*/
|
|
12
13
|
var SideMenuLogotype = forwardRef(function (_a, ref) {
|
|
14
|
+
var _b, _c;
|
|
13
15
|
var productLogo = _a.productLogo, withWidget = _a.withWidget, konturLogo = _a.konturLogo, iconUrl = _a.iconUrl, rest = __rest(_a, ["productLogo", "withWidget", "konturLogo", "iconUrl"]);
|
|
14
16
|
var context = useContext(SideMenuContext);
|
|
15
17
|
var refLogotype = useRef(null);
|
|
16
|
-
var
|
|
18
|
+
var _d = useState(28), size = _d[0], setSize = _d[1];
|
|
17
19
|
useEffect(function () {
|
|
18
20
|
var _a, _b, _c;
|
|
19
21
|
(_a = context.setProductColor) === null || _a === void 0 ? void 0 : _a.call(context, productLogo === null || productLogo === void 0 ? void 0 : productLogo.props.color);
|
|
@@ -42,9 +44,6 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
|
|
|
42
44
|
var getStaticIconPath = function () {
|
|
43
45
|
return "https://s.kontur.ru/common-v2/icons-products/" + productName + "/" + productName + "-32.svg";
|
|
44
46
|
};
|
|
45
|
-
if (context.isMinimized || context.isBeingTransitioned) {
|
|
46
|
-
return React.createElement("img", { className: jsStyles.icon(), src: iconUrl || getStaticIconPath(), alt: productName });
|
|
47
|
-
}
|
|
48
47
|
var getWidget = function (withWidget, isTouchScreen, showWidget) {
|
|
49
48
|
if (withWidget !== undefined) {
|
|
50
49
|
return withWidget;
|
|
@@ -55,8 +54,17 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
|
|
|
55
54
|
return showWidget;
|
|
56
55
|
};
|
|
57
56
|
return (React.createElement("div", { className: jsStyles.root(), ref: ref },
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
!context.isMobile && !context.isTablet && (React.createElement("img", { className: cx((_b = {},
|
|
58
|
+
_b[jsStyles.iconHidden()] = true,
|
|
59
|
+
_b[jsStyles.icon()] = context.isMinimized,
|
|
60
|
+
_b)), src: iconUrl || getStaticIconPath(), alt: productName })),
|
|
61
|
+
React.createElement("div", { className: cx((_c = {},
|
|
62
|
+
_c[jsStyles.logoWrapper()] = true,
|
|
63
|
+
_c[jsStyles.logoWrapperForTabletsOrMobiles()] = context.isMobile || context.isTablet,
|
|
64
|
+
_c[jsStyles.logoWrapperHidden()] = context.isMinimized,
|
|
65
|
+
_c)) },
|
|
66
|
+
(context.isTablet || context.isMobile) && React.createElement(Burger, null),
|
|
67
|
+
React.createElement(Logotype, __assign({ ref: refLogotype, size: size, productLogo: productLogo, konturLogo: konturLogo, withWidget: getWidget(withWidget, context.isTouchScreen, context.showWidget) }, rest)))));
|
|
60
68
|
});
|
|
61
69
|
SideMenuLogotype.displayName = 'SideMenuLogotype';
|
|
62
70
|
var SideMenuLogotypeWithStaticFields = Object.assign(SideMenuLogotype, { __KONTUR_REACT_UI__: 'SideMenuLogotype' });
|
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
import { __makeTemplateObject } from "tslib";
|
|
2
2
|
import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
import { transitionDuration } from '../SideMenu/SideMenu';
|
|
4
|
+
var iconSize = 32;
|
|
5
|
+
var gapBetweenIconAndLogo = 50;
|
|
3
6
|
var styles = {
|
|
7
|
+
root: function () {
|
|
8
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n "], ["\n display: flex;\n "])));
|
|
9
|
+
},
|
|
4
10
|
icon: function () {
|
|
5
|
-
return css(
|
|
11
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n left: 0;\n opacity: 1;\n "], ["\n left: 0;\n opacity: 1;\n "])));
|
|
6
12
|
},
|
|
7
|
-
|
|
8
|
-
return css(
|
|
13
|
+
iconHidden: function () {
|
|
14
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: relative;\n left: -", "px;\n display: block;\n padding-left: 4px;\n opacity: 0;\n transition: all ", "ms ease-out;\n "], ["\n position: relative;\n left: -", "px;\n display: block;\n padding-left: 4px;\n opacity: 0;\n transition: all ", "ms ease-out;\n "])), gapBetweenIconAndLogo, transitionDuration);
|
|
15
|
+
},
|
|
16
|
+
logoWrapper: function () {
|
|
17
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: relative;\n left: -", "px;\n padding-top: 2px;\n padding-bottom: 6px;\n padding-left: 8px;\n display: flex;\n opacity: 1;\n transition: all ", "ms ease-out;\n "], ["\n position: relative;\n left: -", "px;\n padding-top: 2px;\n padding-bottom: 6px;\n padding-left: 8px;\n display: flex;\n opacity: 1;\n transition: all ", "ms ease-out;\n "])), iconSize, transitionDuration);
|
|
18
|
+
},
|
|
19
|
+
logoWrapperForTabletsOrMobiles: function () {
|
|
20
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n padding-top: 8px;\n padding-bottom: 8px;\n left: 0;\n "], ["\n padding-top: 8px;\n padding-bottom: 8px;\n left: 0;\n "])));
|
|
21
|
+
},
|
|
22
|
+
logoWrapperHidden: function () {
|
|
23
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n left: ", "px;\n opacity: 0;\n "], ["\n left: ", "px;\n opacity: 0;\n "])), gapBetweenIconAndLogo - iconSize);
|
|
9
24
|
},
|
|
10
25
|
};
|
|
11
26
|
export var jsStyles = memoizeStyle(styles);
|
|
12
|
-
var templateObject_1, templateObject_2;
|
|
27
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
|
package/src/internal/SubMenu.js
CHANGED
|
@@ -14,7 +14,7 @@ var SubMenu = forwardRef(function (_a, ref) {
|
|
|
14
14
|
if (!children || !isOpened || isSubMenu || shouldHideOverlayMenu) {
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
|
-
if (isSeparatedMenu) {
|
|
17
|
+
if (isSeparatedMenu && (context.isShown || context.isBeingTransitioned)) {
|
|
18
18
|
return (React.createElement(SeparatedSubMenu, { generatedId: generatedId, id: id, href: href, ref: ref, caption: caption }, children));
|
|
19
19
|
}
|
|
20
20
|
return (React.createElement(InnerSubMenu, { generatedId: generatedId, ref: ref }, children));
|