@skbkontur/side-menu 0.6.1 → 0.7.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 +22 -0
- package/README.md +189 -1
- package/hooks/useActiveState.js +5 -5
- package/hooks/useMobileSeparatedMenuScroll.js +2 -2
- package/hooks/useOpenedSubElementState.js +4 -4
- package/package.json +1 -1
- package/src/SideMenu/SideMenu.d.ts +3 -0
- package/src/SideMenu/SideMenu.js +103 -60
- package/src/SideMenu/SideMenu.styles.d.ts +22 -13
- package/src/SideMenu/SideMenu.styles.js +48 -29
- package/src/SideMenuBody/SideMenuBody.js +1 -1
- package/src/SideMenuBody/SideMenuBody.styles.d.ts +1 -1
- package/src/SideMenuBody/SideMenuBody.styles.js +1 -1
- package/src/SideMenuContext.d.ts +9 -6
- package/src/SideMenuDivider/SideMenuDivider.js +1 -1
- package/src/SideMenuDivider/SideMenuDivider.styles.d.ts +1 -1
- package/src/SideMenuDivider/SideMenuDivider.styles.js +1 -1
- package/src/SideMenuDropdown/SideMenuDropdown.js +5 -5
- package/src/SideMenuDropdown/SideMenuDropdown.styles.d.ts +3 -3
- package/src/SideMenuDropdown/SideMenuDropdown.styles.js +3 -3
- package/src/SideMenuFooter/SideMenuFooter.js +1 -1
- package/src/SideMenuFooter/SideMenuFooter.styles.d.ts +1 -1
- package/src/SideMenuFooter/SideMenuFooter.styles.js +1 -1
- package/src/SideMenuHeader/SideMenuHeader.js +8 -8
- package/src/SideMenuHeader/SideMenuHeader.styles.d.ts +5 -5
- package/src/SideMenuHeader/SideMenuHeader.styles.js +5 -5
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.js +1 -1
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.d.ts +2 -2
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.js +2 -2
- package/src/internal/BackButton.js +1 -1
- package/src/internal/Backdrop.js +1 -1
- package/src/internal/Backdrop.styles.d.ts +1 -1
- package/src/internal/Backdrop.styles.js +1 -1
- package/src/internal/Burger.js +1 -1
- package/src/internal/Burger.styles.d.ts +1 -1
- package/src/internal/Burger.styles.js +2 -2
- package/src/internal/ClickableElement.js +53 -17
- package/src/internal/ClickableElement.styles.d.ts +5 -5
- package/src/internal/ClickableElement.styles.js +5 -5
- package/src/internal/InnerBody.js +1 -1
- package/src/internal/InnerBody.styles.d.ts +1 -1
- package/src/internal/InnerBody.styles.js +1 -1
- package/src/internal/ItemContent/Caption.js +13 -13
- package/src/internal/ItemContent/Caption.styles.d.ts +12 -12
- package/src/internal/ItemContent/Caption.styles.js +12 -12
- package/src/internal/ItemContent/Icon.js +8 -8
- package/src/internal/ItemContent/Icon.styles.d.ts +8 -8
- package/src/internal/ItemContent/Icon.styles.js +8 -8
- package/src/internal/ItemContent/ItemContent.js +10 -10
- package/src/internal/ItemContent/ItemContent.styles.d.ts +8 -8
- package/src/internal/ItemContent/ItemContent.styles.js +8 -8
- package/src/internal/ItemContent/Marker.js +2 -2
- package/src/internal/ItemContent/Marker.styles.d.ts +2 -2
- package/src/internal/ItemContent/Marker.styles.js +2 -2
- package/src/internal/NestedMenu.js +1 -1
- package/src/internal/NestedMenu.styles.d.ts +1 -1
- package/src/internal/NestedMenu.styles.js +1 -1
- package/src/internal/RightBorder.d.ts +1 -1
- package/src/internal/RightBorder.js +5 -5
- package/src/internal/RightBorder.styles.d.ts +3 -3
- package/src/internal/RightBorder.styles.js +3 -3
- package/src/internal/SeparatedSubMenu.js +10 -4
- package/src/internal/SeparatedSubMenu.styles.d.ts +5 -2
- package/src/internal/SeparatedSubMenu.styles.js +13 -3
- package/src/internal/SideMenuLogotype.js +3 -3
- package/src/internal/SideMenuLogotype.styles.d.ts +2 -2
- package/src/internal/SideMenuLogotype.styles.js +2 -2
- package/src/internal/SubMenu.d.ts +1 -1
- package/src/internal/SubMenu.js +6 -3
- package/utils/scripts.d.ts +2 -2
- package/utils/scripts.js +5 -4
|
@@ -1,49 +1,68 @@
|
|
|
1
1
|
import { __makeTemplateObject } from "tslib";
|
|
2
2
|
import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
|
+
export var sideMenuMinimizedWidth = '72px';
|
|
4
|
+
export var sideMenuStandardWidth = '232px';
|
|
5
|
+
export var sideMenuForTouchScreenWidth = '328px';
|
|
6
|
+
export var sideMenuBoxShadow = '4px 4px 24px rgba(0, 0, 0, 0.24)';
|
|
3
7
|
var styles = {
|
|
4
|
-
|
|
5
|
-
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n height: 100%;\n "], ["\n position: relative;\n height: 100%;\n "])));
|
|
8
|
+
root: function () {
|
|
9
|
+
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 "])));
|
|
6
10
|
},
|
|
7
|
-
|
|
8
|
-
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n "], ["\n position: absolute;\n top: 0;\n "])));
|
|
11
|
+
rootForTabletsOrMobiles: function () {
|
|
12
|
+
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 "])));
|
|
9
13
|
},
|
|
10
|
-
|
|
11
|
-
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n
|
|
14
|
+
shownRootForTabletsOrMobiles: function () {
|
|
15
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n height: 100vh;\n "], ["\n height: 100vh;\n "])));
|
|
16
|
+
},
|
|
17
|
+
rootForNarrowDesktops: function () {
|
|
18
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: ", ";\n "], ["\n width: ", ";\n "])), sideMenuMinimizedWidth);
|
|
19
|
+
},
|
|
20
|
+
separatedRootForNarrowDesktops: function () {
|
|
21
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n width: calc(", " + ", ");\n background: #fff;\n "], ["\n width: calc(", " + ", ");\n background: #fff;\n "])), sideMenuMinimizedWidth, sideMenuStandardWidth);
|
|
12
22
|
},
|
|
13
|
-
|
|
14
|
-
return css(
|
|
23
|
+
separatedRootForDesktops: function () {
|
|
24
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n width: calc(", " + ", ");\n background: #fff;\n "], ["\n width: calc(", " + ", ");\n background: #fff;\n "])), sideMenuStandardWidth, sideMenuStandardWidth);
|
|
15
25
|
},
|
|
16
|
-
|
|
17
|
-
return css(
|
|
26
|
+
container: function () {
|
|
27
|
+
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 1s;\n "], ["\n width: ", ";\n height: 100%;\n background: #f6f6f6;\n position: relative;\n box-sizing: border-box;\n transition: width 1s;\n "])), sideMenuStandardWidth);
|
|
18
28
|
},
|
|
19
|
-
|
|
20
|
-
return css(
|
|
29
|
+
containerSafari: function () {
|
|
30
|
+
return css(templateObject_8 || (templateObject_8 = __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 "])));
|
|
21
31
|
},
|
|
22
|
-
|
|
23
|
-
return css(
|
|
32
|
+
contentWrapperWithoutScrollBar: function () {
|
|
33
|
+
return css(templateObject_9 || (templateObject_9 = __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 "])));
|
|
24
34
|
},
|
|
25
|
-
|
|
26
|
-
return css(
|
|
35
|
+
collapsedContentWrapperForTabletsOrMobiles: function () {
|
|
36
|
+
return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n overflow: hidden;\n "], ["\n overflow: hidden;\n "])));
|
|
27
37
|
},
|
|
28
|
-
|
|
29
|
-
return css(
|
|
38
|
+
minimizedContainer: function () {
|
|
39
|
+
return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n width: ", " !important;\n "], ["\n width: ", " !important;\n "])), sideMenuMinimizedWidth);
|
|
30
40
|
},
|
|
31
|
-
|
|
32
|
-
return css(
|
|
41
|
+
innerContainer: function () {
|
|
42
|
+
return css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n overflow-x: hidden;\n "], ["\n overflow-x: hidden;\n "])));
|
|
33
43
|
},
|
|
34
|
-
|
|
35
|
-
return css(
|
|
44
|
+
containerForTouchScreens: function () {
|
|
45
|
+
return css(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n width: ", ";\n "], ["\n width: ", ";\n "])), sideMenuForTouchScreenWidth);
|
|
36
46
|
},
|
|
37
|
-
|
|
38
|
-
return css(
|
|
47
|
+
separatedContainerForMobiles: function () {
|
|
48
|
+
return css(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n background: #fff;\n "], ["\n background: #fff;\n "])));
|
|
39
49
|
},
|
|
40
|
-
|
|
50
|
+
contentWrapper: function () {
|
|
51
|
+
return css(templateObject_15 || (templateObject_15 = __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 "])));
|
|
52
|
+
},
|
|
53
|
+
wrapper: function () {
|
|
54
|
+
return css(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n height: 100%;\n display: inline-flex;\n position: relative;\n "], ["\n height: 100%;\n display: inline-flex;\n position: relative;\n "])));
|
|
55
|
+
},
|
|
56
|
+
wrapperIE: function () {
|
|
41
57
|
var ieRootWrapperCorrection = 15;
|
|
42
|
-
return css(
|
|
58
|
+
return css(templateObject_17 || (templateObject_17 = __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);
|
|
59
|
+
},
|
|
60
|
+
wrapperWithShadow: function () {
|
|
61
|
+
return css(templateObject_18 || (templateObject_18 = __makeTemplateObject(["\n box-shadow: ", ";\n "], ["\n box-shadow: ", ";\n "])), sideMenuBoxShadow);
|
|
43
62
|
},
|
|
44
|
-
|
|
45
|
-
return css(
|
|
63
|
+
collapsedContainerForTabletsOrMobiles: function () {
|
|
64
|
+
return css(templateObject_19 || (templateObject_19 = __makeTemplateObject(["\n background-color: transparent;\n "], ["\n background-color: transparent;\n "])));
|
|
46
65
|
},
|
|
47
66
|
};
|
|
48
67
|
export var jsStyles = memoizeStyle(styles);
|
|
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;
|
|
68
|
+
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, templateObject_17, templateObject_18, templateObject_19;
|
|
@@ -9,7 +9,7 @@ var SideMenuBodyInner = forwardRef(function (_a, ref) {
|
|
|
9
9
|
var className = _a.className, children = _a.children, rest = __rest(_a, ["className", "children"]);
|
|
10
10
|
var context = useContext(SideMenuContext);
|
|
11
11
|
if (context.isShown) {
|
|
12
|
-
return (React.createElement("div", __assign({ className: cx((_b = {}, _b[jsStyles.
|
|
12
|
+
return (React.createElement("div", __assign({ className: cx((_b = {}, _b[jsStyles.root()] = true, _b), className), ref: ref }, rest),
|
|
13
13
|
React.createElement(InnerBody, null, children)));
|
|
14
14
|
}
|
|
15
15
|
return null;
|
|
@@ -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
|
+
root: function () {
|
|
5
5
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n flex-grow: 1;\n padding-bottom: 16px;\n margin-top: 0;\n "], ["\n flex-grow: 1;\n padding-bottom: 16px;\n margin-top: 0;\n "])));
|
|
6
6
|
},
|
|
7
7
|
};
|
package/src/SideMenuContext.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FlattedArrayElementType } from './internal/InnerBody';
|
|
2
2
|
export interface SideMenuContextType {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
isMinimized?: boolean;
|
|
4
|
+
setIsMinimized?: (isMinimized: boolean) => void;
|
|
5
|
+
isBeingTransitioned?: boolean;
|
|
5
6
|
isSeparatedMenu?: boolean;
|
|
6
7
|
size?: 'small' | 'large';
|
|
7
8
|
activeMenuItem?: string | null;
|
|
@@ -19,9 +20,11 @@ export interface SideMenuContextType {
|
|
|
19
20
|
isShown?: boolean;
|
|
20
21
|
toggleIsShown?: () => void;
|
|
21
22
|
flattedArrayOfAllElements?: FlattedArrayElementType[];
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
isSeparatedMenuShown?: boolean;
|
|
24
|
+
setIsSeparatedMenuShown?: (separatedMenuIsShown: boolean) => void;
|
|
25
|
+
separatedMenuWithoutOverlay?: boolean;
|
|
26
|
+
setIsMouseOutside?: (v: boolean) => void;
|
|
27
|
+
isMobileSeparatedMenuScrolling?: boolean;
|
|
28
|
+
setIsMobileSeparatedMenuScrolling?: (isScrolling: boolean) => void;
|
|
26
29
|
}
|
|
27
30
|
export declare const SideMenuContext: import("react").Context<SideMenuContextType>;
|
|
@@ -5,7 +5,7 @@ import { jsStyles } from './SideMenuDivider.styles';
|
|
|
5
5
|
var SideMenuDividerInner = forwardRef(function (_a, ref) {
|
|
6
6
|
var _b;
|
|
7
7
|
var className = _a.className, rest = __rest(_a, ["className"]);
|
|
8
|
-
return React.createElement("hr", __assign({ className: cx((_b = {}, _b[jsStyles.
|
|
8
|
+
return React.createElement("hr", __assign({ className: cx((_b = {}, _b[jsStyles.root()] = true, _b), className), ref: ref }, rest));
|
|
9
9
|
});
|
|
10
10
|
SideMenuDividerInner.displayName = 'SideMenuDivider';
|
|
11
11
|
/**
|
|
@@ -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
|
+
root: function () {
|
|
5
5
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background: #ebebeb;\n height: 1px;\n border: none;\n margin: 4px 12px 4px 32px;\n "], ["\n background: #ebebeb;\n height: 1px;\n border: none;\n margin: 4px 12px 4px 32px;\n "])));
|
|
6
6
|
},
|
|
7
7
|
};
|
|
@@ -11,8 +11,8 @@ var SideMenuDropdownInner = forwardRef(function (_a, ref) {
|
|
|
11
11
|
var icon = _a.icon, id = _a.id, _generatedId = _a._generatedId, _avatar = _a._avatar, children = _a.children, _d = _a.caption, caption = _d === void 0 ? 'СКБ Контур' : _d, className = _a.className, _e = _a.disableAnimations, disableAnimations = _e === void 0 ? false : _e, menuWidth = _a.menuWidth, rest = __rest(_a, ["icon", "id", "_generatedId", "_avatar", "children", "caption", "className", "disableAnimations", "menuWidth"]);
|
|
12
12
|
var context = useContext(SideMenuContext);
|
|
13
13
|
var label = (React.createElement("div", { className: cx((_b = {},
|
|
14
|
-
_b[jsStyles.
|
|
15
|
-
_b[jsStyles.
|
|
14
|
+
_b[jsStyles.label()] = true,
|
|
15
|
+
_b[jsStyles.minimizedLabel()] = context.isMinimized,
|
|
16
16
|
_b)) },
|
|
17
17
|
React.createElement(SideMenuItem, { icon: icon, caption: caption, _avatar: _avatar, id: id, _isDropdown: true })));
|
|
18
18
|
return (React.createElement(ThemeContext.Provider, { value: ThemeFactory.create({
|
|
@@ -21,15 +21,15 @@ var SideMenuDropdownInner = forwardRef(function (_a, ref) {
|
|
|
21
21
|
popupBorderRadius: '8px',
|
|
22
22
|
menuItemPaddingX: '32px',
|
|
23
23
|
}, DEFAULT_THEME) },
|
|
24
|
-
React.createElement("div", { className: cx((_c = {}, _c[jsStyles.
|
|
24
|
+
React.createElement("div", { className: cx((_c = {}, _c[jsStyles.wrapper()] = true, _c), className), ref: ref },
|
|
25
25
|
React.createElement(DropdownMenu, __assign({ caption: label, positions: ['top left'], disableAnimations: true, menuWidth: menuWidth }, rest), React.Children.map(children, function (child) {
|
|
26
26
|
// @ts-expect-error: accessing private property
|
|
27
27
|
if (React.isValidElement(child) && (child === null || child === void 0 ? void 0 : child.type.__KONTUR_REACT_UI__) === 'MenuItem') {
|
|
28
28
|
return React.cloneElement(child, {
|
|
29
29
|
onClick: function () {
|
|
30
|
-
var _a;
|
|
30
|
+
var _a, _b, _c;
|
|
31
31
|
(_a = context.toggleIsShown) === null || _a === void 0 ? void 0 : _a.call(context);
|
|
32
|
-
child.props.onClick();
|
|
32
|
+
(_c = (_b = child.props).onClick) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
33
33
|
},
|
|
34
34
|
});
|
|
35
35
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { __makeTemplateObject } from "tslib";
|
|
2
2
|
import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
3
|
var styles = {
|
|
4
|
-
|
|
4
|
+
label: function () {
|
|
5
5
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 200px;\n transition: width 1s;\n "], ["\n width: 200px;\n transition: width 1s;\n "])));
|
|
6
6
|
},
|
|
7
|
-
|
|
7
|
+
minimizedLabel: function () {
|
|
8
8
|
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: 100%;\n "], ["\n width: 100%;\n "])));
|
|
9
9
|
},
|
|
10
|
-
|
|
10
|
+
wrapper: function () {
|
|
11
11
|
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n overflow-x: hidden;\n "], ["\n overflow-x: hidden;\n "])));
|
|
12
12
|
},
|
|
13
13
|
};
|
|
@@ -9,7 +9,7 @@ var SideMenuFooterInner = forwardRef(function (_a, ref) {
|
|
|
9
9
|
var className = _a.className, children = _a.children, rest = __rest(_a, ["className", "children"]);
|
|
10
10
|
var context = useContext(SideMenuContext);
|
|
11
11
|
if (context.isShown) {
|
|
12
|
-
return (React.createElement("footer", __assign({ className: cx((_b = {}, _b[jsStyles.
|
|
12
|
+
return (React.createElement("footer", __assign({ className: cx((_b = {}, _b[jsStyles.root()] = true, _b), className), ref: ref }, rest), React.Children.map(children, function (child, index) {
|
|
13
13
|
if (React.isValidElement(child)) {
|
|
14
14
|
return React.cloneElement(child, {
|
|
15
15
|
_generatedId: getItemId('footer', index++),
|
|
@@ -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
|
+
root: function () {
|
|
5
5
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n flex-grow: 0;\n "], ["\n flex-grow: 0;\n "])));
|
|
6
6
|
},
|
|
7
7
|
};
|
|
@@ -20,7 +20,7 @@ var SideMenuHeaderInner = forwardRef(function (_a, ref) {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
useEffect(function () {
|
|
23
|
-
if (!context.
|
|
23
|
+
if (!context.isSeparatedMenuShown) {
|
|
24
24
|
window.addEventListener('scroll', checkFixed, true);
|
|
25
25
|
}
|
|
26
26
|
return function () {
|
|
@@ -28,14 +28,14 @@ var SideMenuHeaderInner = forwardRef(function (_a, ref) {
|
|
|
28
28
|
};
|
|
29
29
|
});
|
|
30
30
|
useEffect(function () {
|
|
31
|
-
context.
|
|
32
|
-
}, [context.
|
|
31
|
+
context.isMobileSeparatedMenuScrolling !== undefined && setIsFixed(context.isMobileSeparatedMenuScrolling);
|
|
32
|
+
}, [context.isMobileSeparatedMenuScrolling]);
|
|
33
33
|
return (React.createElement("header", __assign({ className: cx((_b = {},
|
|
34
|
-
_b[jsStyles.
|
|
35
|
-
_b[jsStyles.
|
|
36
|
-
_b[jsStyles.
|
|
37
|
-
_b[jsStyles.
|
|
38
|
-
_b[jsStyles.
|
|
34
|
+
_b[jsStyles.root()] = true,
|
|
35
|
+
_b[jsStyles.fixedRoot()] = isFixed,
|
|
36
|
+
_b[jsStyles.minimizedRoot()] = context.isMinimized || context.isBeingTransitioned,
|
|
37
|
+
_b[jsStyles.collapsedRootForTabletsOrMobiles()] = !context.isShown,
|
|
38
|
+
_b[jsStyles.rootWithSeparatedMenuShown()] = context.isShown && context.isMobile && context.isSeparatedMenuShown,
|
|
39
39
|
_b), className), ref: mergeRefs([headerWrapperRef, ref]), style: style }, rest),
|
|
40
40
|
React.createElement(SideMenuLogotype, __assign({ productLogo: productLogo, konturLogo: konturLogo, iconUrl: iconUrl, withWidget: withWidget }, rest))));
|
|
41
41
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const jsStyles: {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
root(): string;
|
|
3
|
+
minimizedRoot(): string;
|
|
4
|
+
collapsedRootForTabletsOrMobiles(): string;
|
|
5
|
+
rootWithSeparatedMenuShown(): string;
|
|
6
|
+
fixedRoot(): string;
|
|
7
7
|
};
|
|
@@ -2,19 +2,19 @@ import { __makeTemplateObject } from "tslib";
|
|
|
2
2
|
import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
3
3
|
var headerWrapperPaddingX = '8px';
|
|
4
4
|
var styles = {
|
|
5
|
-
|
|
5
|
+
root: function () {
|
|
6
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);
|
|
7
7
|
},
|
|
8
|
-
|
|
8
|
+
minimizedRoot: function () {
|
|
9
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 "])));
|
|
10
10
|
},
|
|
11
|
-
|
|
11
|
+
collapsedRootForTabletsOrMobiles: function () {
|
|
12
12
|
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background: transparent;\n "], ["\n background: transparent;\n "])));
|
|
13
13
|
},
|
|
14
|
-
|
|
14
|
+
rootWithSeparatedMenuShown: function () {
|
|
15
15
|
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n background: #fff;\n "], ["\n background: #fff;\n "])));
|
|
16
16
|
},
|
|
17
|
-
|
|
17
|
+
fixedRoot: function () {
|
|
18
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 "])));
|
|
19
19
|
},
|
|
20
20
|
};
|
|
@@ -7,7 +7,7 @@ var SideMenuSubItemHeaderInner = forwardRef(function (_a, ref) {
|
|
|
7
7
|
var _b;
|
|
8
8
|
var className = _a.className, children = _a.children, rest = __rest(_a, ["className", "children"]);
|
|
9
9
|
var context = useContext(SideMenuContext);
|
|
10
|
-
return (React.createElement("p", __assign({ className: cx((_b = {}, _b[jsStyles.
|
|
10
|
+
return (React.createElement("p", __assign({ className: cx((_b = {}, _b[jsStyles.root()] = true, _b[jsStyles.rootInSeparatedSubMenu()] = context.isSeparatedMenu, _b), className), ref: ref }, rest), children));
|
|
11
11
|
});
|
|
12
12
|
SideMenuSubItemHeaderInner.displayName = 'SideMenuSubItemHeader';
|
|
13
13
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
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
5
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n font-size: 12px;\n color: rgba(0, 0, 0, 0.48);\n padding: 10px 8px 2px 40px;\n margin: 0;\n "], ["\n font-size: 12px;\n color: rgba(0, 0, 0, 0.48);\n padding: 10px 8px 2px 40px;\n margin: 0;\n "])));
|
|
6
6
|
},
|
|
7
|
-
|
|
7
|
+
rootInSeparatedSubMenu: function () {
|
|
8
8
|
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding-left: 8px;\n "], ["\n padding-left: 8px;\n "])));
|
|
9
9
|
},
|
|
10
10
|
};
|
|
@@ -13,7 +13,7 @@ var BackButton = forwardRef(function (_a, ref) {
|
|
|
13
13
|
var context = useContext(SideMenuContext);
|
|
14
14
|
return (React.createElement(SideMenuItem, { "data-tid": SideMenuDataTids.backButton, icon: React.createElement(ArrowALeftIcon20Regular, null), caption: caption, _isDropdown: true, _isSubMenu: true, onClick: function () {
|
|
15
15
|
var _a, _b, _c, _d;
|
|
16
|
-
(_a = context.
|
|
16
|
+
(_a = context.setIsSeparatedMenuShown) === null || _a === void 0 ? void 0 : _a.call(context, false);
|
|
17
17
|
if (id) {
|
|
18
18
|
(_b = context.switchActiveMenuItem) === null || _b === void 0 ? void 0 : _b.call(context, id);
|
|
19
19
|
}
|
package/src/internal/Backdrop.js
CHANGED
|
@@ -6,7 +6,7 @@ import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
|
6
6
|
export var Backdrop = function () {
|
|
7
7
|
var _a;
|
|
8
8
|
return (React.createElement("div", { className: cx((_a = {},
|
|
9
|
-
_a[jsStyles.
|
|
9
|
+
_a[jsStyles.rootForTabletsOrMobiles()] = true,
|
|
10
10
|
_a)), style: {
|
|
11
11
|
background: DEFAULT_THEME.sidePageBackingBg,
|
|
12
12
|
opacity: DEFAULT_THEME.sidePageBackingBgOpacity,
|
|
@@ -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
|
+
rootForTabletsOrMobiles: 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
|
@@ -5,6 +5,6 @@ import { UiMenuBarsThreeHIcon24Regular } from '@skbkontur/icons';
|
|
|
5
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.rootForTabletsOrMobiles(), onClick: context.toggleIsShown, "data-tid": SideMenuDataTids.burger },
|
|
9
9
|
React.createElement(UiMenuBarsThreeHIcon24Regular, null)));
|
|
10
10
|
};
|
|
@@ -2,8 +2,8 @@ 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
|
-
|
|
6
|
-
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n margin-right: 8px;\n "], ["\n ", ";\n margin-right: 8px;\n "])), resetButton());
|
|
5
|
+
rootForTabletsOrMobiles: function () {
|
|
6
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n margin-right: 8px;\n cursor: pointer;\n "], ["\n ", ";\n margin-right: 8px;\n cursor: pointer;\n "])), resetButton());
|
|
7
7
|
},
|
|
8
8
|
};
|
|
9
9
|
export var jsStyles = memoizeStyle(styles);
|
|
@@ -18,17 +18,16 @@ var ClickableElement = forwardRef(function (_a, ref) {
|
|
|
18
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
|
-
var _c = useState(false),
|
|
22
|
-
var isOpened = useOpenedState(id || rest.href, _generatedId, context.openedParents, isActive, children, context.
|
|
21
|
+
var _c = useState(false), isFocusedByTab = _c[0], setIsFocusedByTab = _c[1];
|
|
22
|
+
var isOpened = useOpenedState(id || rest.href, _generatedId, context.openedParents, isActive, children, context.isSeparatedMenuShown, context.isMobile && context.isSeparatedMenu);
|
|
23
23
|
var hasChildren = function (id, generatedId) {
|
|
24
24
|
var _a, _b;
|
|
25
25
|
var parentId = id ? 'id' : 'generatedParentId';
|
|
26
26
|
var childId = id !== null && id !== void 0 ? id : generatedId;
|
|
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
|
-
var
|
|
30
|
-
var _a, _b, _c
|
|
31
|
-
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
29
|
+
var switchActiveItem = function () {
|
|
30
|
+
var _a, _b, _c;
|
|
32
31
|
if (id) {
|
|
33
32
|
(_a = context.switchActiveMenuItem) === null || _a === void 0 ? void 0 : _a.call(context, id);
|
|
34
33
|
}
|
|
@@ -38,35 +37,72 @@ var ClickableElement = forwardRef(function (_a, ref) {
|
|
|
38
37
|
else if (_generatedId) {
|
|
39
38
|
(_c = context.switchActiveMenuItem) === null || _c === void 0 ? void 0 : _c.call(context, _generatedId);
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
};
|
|
41
|
+
var toggleIsShown = function (lastElementInTheHierarchy) {
|
|
42
|
+
var _a;
|
|
43
|
+
if ((context.isMobile || context.isTablet) && lastElementInTheHierarchy) {
|
|
44
|
+
(_a = context.toggleIsShown) === null || _a === void 0 ? void 0 : _a.call(context);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var setIsMinimized = function (lastElementInTheHierarchy) {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
var topLevelItemInSideMenuWithOverlay = context.separatedMenuWithoutOverlay && !_isSubMenu && children;
|
|
50
|
+
if (context.isNarrowDesktop && (lastElementInTheHierarchy || topLevelItemInSideMenuWithOverlay)) {
|
|
51
|
+
(_a = context.setIsMinimized) === null || _a === void 0 ? void 0 : _a.call(context, true);
|
|
52
|
+
}
|
|
53
|
+
if (!_isSubMenu) {
|
|
54
|
+
(_b = context.setIsMinimized) === null || _b === void 0 ? void 0 : _b.call(context, false);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var setMouseIsOutside = function (lastElementInTheHierarchy) {
|
|
58
|
+
var _a;
|
|
59
|
+
if (lastElementInTheHierarchy) {
|
|
60
|
+
(_a = context.setIsMouseOutside) === null || _a === void 0 ? void 0 : _a.call(context, true);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var setSeparatedMenuIsShown = function () {
|
|
64
|
+
var _a, _b;
|
|
65
|
+
if (!_isSubMenu && context.separatedMenuWithoutOverlay) {
|
|
66
|
+
(_a = context.setIsSeparatedMenuShown) === null || _a === void 0 ? void 0 : _a.call(context, false);
|
|
43
67
|
}
|
|
44
68
|
if (context.isSeparatedMenu && !_isSubMenu && children) {
|
|
45
|
-
(
|
|
69
|
+
(_b = context.setIsSeparatedMenuShown) === null || _b === void 0 ? void 0 : _b.call(context, true);
|
|
46
70
|
}
|
|
47
71
|
};
|
|
72
|
+
var handleClick = function (e) {
|
|
73
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
74
|
+
var lastElementInTheHierarchy = !hasChildren(id || rest.href, _generatedId) && !_isDropdown;
|
|
75
|
+
switchActiveItem();
|
|
76
|
+
toggleIsShown(lastElementInTheHierarchy);
|
|
77
|
+
setIsMinimized(lastElementInTheHierarchy);
|
|
78
|
+
setMouseIsOutside(lastElementInTheHierarchy);
|
|
79
|
+
setSeparatedMenuIsShown();
|
|
80
|
+
};
|
|
48
81
|
var handleFocus = function (e) {
|
|
49
82
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
50
83
|
requestAnimationFrame(function () {
|
|
51
84
|
if (keyListener.isTabPressed) {
|
|
52
|
-
|
|
85
|
+
setIsFocusedByTab(true);
|
|
53
86
|
}
|
|
54
87
|
});
|
|
55
88
|
};
|
|
56
89
|
var handleBlur = function (e) {
|
|
57
90
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
58
|
-
|
|
91
|
+
setIsFocusedByTab(false);
|
|
59
92
|
};
|
|
60
|
-
var
|
|
93
|
+
var shouldHighlightTopLevelItemWhenSubItemSelectedInSeparatedMenu = isOpened && !_isSubMenu && context.isSeparatedMenu;
|
|
94
|
+
var shouldHighlightTopLevelItemWhenMenuIsMinimized = isOpened && !_isSubMenu && context.isNarrowDesktop && context.isMinimized;
|
|
61
95
|
return (React.createElement("div", null,
|
|
62
96
|
React.cloneElement(React.createElement(Tag, null), __assign({ className: cx((_b = {},
|
|
63
|
-
_b[jsStyles.
|
|
64
|
-
_b[jsStyles.
|
|
65
|
-
_b[jsStyles.
|
|
66
|
-
_b[jsStyles.
|
|
67
|
-
|
|
97
|
+
_b[jsStyles.root()] = true,
|
|
98
|
+
_b[jsStyles.rootSubItem()] = context.isSeparatedMenu && _isSubMenu,
|
|
99
|
+
_b[jsStyles.focusedRoot()] = isFocusedByTab,
|
|
100
|
+
_b[jsStyles.activeRoot()] = isActive ||
|
|
101
|
+
shouldHighlightTopLevelItemWhenSubItemSelectedInSeparatedMenu ||
|
|
102
|
+
shouldHighlightTopLevelItemWhenMenuIsMinimized,
|
|
103
|
+
_b[jsStyles.activeRootSubItemInSeparatedSubMenu()] = isActive && context.isSeparatedMenu && _isSubMenu,
|
|
68
104
|
_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,
|
|
105
|
+
React.createElement(SubMenu, { generatedId: _generatedId, id: id, href: rest.href, caption: caption, isSubMenu: _isSubMenu, isSeparatedMenu: context.isSeparatedMenu, isOpened: isOpened, isMinimized: context.isMinimized }, children)));
|
|
70
106
|
});
|
|
71
107
|
ClickableElement.displayName = 'ClickableElement';
|
|
72
108
|
var ClickableElementWithStaticFields = Object.assign(ClickableElement, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const jsStyles: {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
root(): string;
|
|
3
|
+
rootSubItem(): string;
|
|
4
|
+
focusedRoot(): string;
|
|
5
|
+
activeRoot(): string;
|
|
6
|
+
activeRootSubItemInSeparatedSubMenu(): string;
|
|
7
7
|
};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
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
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: #f6f6f6;\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: #f6f6f6;\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
9
|
},
|
|
10
|
-
|
|
10
|
+
focusedRoot: function () {
|
|
11
11
|
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n box-shadow: inset 0 0 0 2px #1c7edf;\n "], ["\n box-shadow: inset 0 0 0 2px #1c7edf;\n "])));
|
|
12
12
|
},
|
|
13
|
-
|
|
13
|
+
activeRoot: function () {
|
|
14
14
|
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n background: #fff !important;\n "], ["\n background: #fff !important;\n "])));
|
|
15
15
|
},
|
|
16
|
-
|
|
16
|
+
activeRootSubItemInSeparatedSubMenu: function () {
|
|
17
17
|
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n background: #f2f2f2 !important;\n "], ["\n background: #f2f2f2 !important;\n "])));
|
|
18
18
|
},
|
|
19
19
|
};
|
|
@@ -52,7 +52,7 @@ var InnerBody = function (_a) {
|
|
|
52
52
|
// @ts-expect-error: accessing private property
|
|
53
53
|
if ((child === null || child === void 0 ? void 0 : child.type.__KONTUR_REACT_UI__) === 'SideMenuDivider') {
|
|
54
54
|
return React.cloneElement(child, {
|
|
55
|
-
className: jsStyles.
|
|
55
|
+
className: jsStyles.divider(),
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
if (
|