@skbkontur/side-menu 5.0.0-alpha.1 → 5.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/internal/themes/SideMenuDarkTheme.js +3 -1
- package/internal/themes/SideMenuTheme.d.ts +25 -3
- package/internal/themes/SideMenuTheme.js +41 -13
- package/package.json +2 -2
- package/src/SideMenu/SideMenu.d.ts +3 -0
- package/src/SideMenu/SideMenu.js +90 -54
- package/src/SideMenu/SideMenu.styles.d.ts +4 -0
- package/src/SideMenu/SideMenu.styles.js +28 -11
- package/src/SideMenuBody/SideMenuBody.js +2 -0
- package/src/SideMenuBody/SideMenuBody.styles.js +1 -1
- package/src/SideMenuDivider/SideMenuDivider.js +4 -1
- package/src/SideMenuDivider/SideMenuDivider.styles.d.ts +1 -0
- package/src/SideMenuDivider/SideMenuDivider.styles.js +5 -2
- package/src/SideMenuDropdown/SideMenuDropdown.js +7 -7
- package/src/SideMenuDropdown/SideMenuDropdown.styles.d.ts +1 -0
- package/src/SideMenuDropdown/SideMenuDropdown.styles.js +8 -4
- package/src/SideMenuFooter/SideMenuFooter.js +41 -5
- package/src/SideMenuFooter/SideMenuFooter.styles.d.ts +7 -0
- package/src/SideMenuFooter/SideMenuFooter.styles.js +30 -8
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.js +1 -1
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.d.ts +1 -1
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.js +2 -2
- package/src/internal/ClickableElement.js +1 -0
- package/src/internal/ClickableElement.styles.d.ts +1 -0
- package/src/internal/ClickableElement.styles.js +16 -11
- package/src/internal/CollapseToggle.js +6 -2
- package/src/internal/CollapseToggle.styles.d.ts +2 -0
- package/src/internal/CollapseToggle.styles.js +7 -1
- package/src/internal/ItemContent/Caption.js +1 -0
- package/src/internal/ItemContent/Caption.styles.d.ts +1 -0
- package/src/internal/ItemContent/Caption.styles.js +16 -13
- package/src/internal/ItemContent/Icon.js +2 -0
- package/src/internal/ItemContent/Icon.styles.d.ts +2 -0
- package/src/internal/ItemContent/Icon.styles.js +14 -8
- package/src/internal/ItemContent/Marker.js +8 -2
- package/src/internal/ItemContent/Marker.styles.d.ts +3 -0
- package/src/internal/ItemContent/Marker.styles.js +16 -5
- package/src/internal/NarrowAccordionDropdown.js +8 -8
|
@@ -6,27 +6,33 @@ export var getStyles = memoizeGetStyles(function (_a) {
|
|
|
6
6
|
root: function (t) {
|
|
7
7
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n margin: ", " ", " ", " ", ";\n min-height: ", ";\n line-height: ", ";\n flex-shrink: 0;\n box-sizing: content-box;\n "], ["\n display: flex;\n align-items: center;\n margin: ", " ", " ", " ", ";\n min-height: ", ";\n line-height: ", ";\n flex-shrink: 0;\n box-sizing: content-box;\n "])), t.sideMenuIconMarginY, t.sideMenuIconMarginRight, t.sideMenuIconMarginY, t.sideMenuIconMarginLeft, t.sideMenuIconMinHeight, t.sideMenuIconLineHeight);
|
|
8
8
|
},
|
|
9
|
+
rootCollapsed: function (t) {
|
|
10
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin-left: ", ";\n "], ["\n margin-left: ", ";\n "])), t.sideMenuIconMarginLeftCollapsed);
|
|
11
|
+
},
|
|
12
|
+
rootCollapsedLarge: function (t) {
|
|
13
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n margin-left: ", ";\n margin-right: ", ";\n "], ["\n margin-left: ", ";\n margin-right: ", ";\n "])), t.sideMenuIconMarginXCollapsedLarge, t.sideMenuIconMarginXCollapsedLarge);
|
|
14
|
+
},
|
|
9
15
|
rootMultiline: function () {
|
|
10
|
-
return css(
|
|
16
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n align-self: flex-start;\n margin-top: -2px;\n "], ["\n align-self: flex-start;\n margin-top: -2px;\n "])));
|
|
11
17
|
},
|
|
12
18
|
rootLarge: function (t) {
|
|
13
|
-
return css(
|
|
19
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n min-height: ", ";\n line-height: ", ";\n margin-top: 0;\n "], ["\n min-height: ", ";\n line-height: ", ";\n margin-top: 0;\n "])), t.sideMenuIconMinHeightLarge, t.sideMenuIconLineHeightLarge);
|
|
14
20
|
},
|
|
15
21
|
rootSubItemLarge: function (t) {
|
|
16
|
-
return css(
|
|
22
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n min-height: ", ";\n "], ["\n min-height: ", ";\n "])), t.sideMenuIconSubItemMinHeightLarge);
|
|
17
23
|
},
|
|
18
24
|
rootSubItem: function (t) {
|
|
19
|
-
return css(
|
|
25
|
+
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n margin: 0;\n padding-left: ", ";\n padding-right: ", ";\n min-height: ", ";\n line-height: ", ";\n "], ["\n margin: 0;\n padding-left: ", ";\n padding-right: ", ";\n min-height: ", ";\n line-height: ", ";\n "])), t.sideMenuIconSubItemPaddingLeft, t.sideMenuIconSubItemPaddingRight, t.sideMenuIconSubItemMinHeight, t.sideMenuIconSubItemLineHeight);
|
|
20
26
|
},
|
|
21
27
|
rootSubItemDropdown: function () {
|
|
22
|
-
return css(
|
|
28
|
+
return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n padding-left: 0;\n "], ["\n padding-left: 0;\n "])));
|
|
23
29
|
},
|
|
24
30
|
rootSubItemSeparatedMenu: function (t) {
|
|
25
|
-
return css(
|
|
31
|
+
return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n padding-left: ", ";\n "], ["\n padding-left: ", ";\n "])), t.sideMenuIconWithSeparatedSubMenuSubItemPaddingLeft);
|
|
26
32
|
},
|
|
27
33
|
rootBackButton: function (t) {
|
|
28
|
-
return css(
|
|
34
|
+
return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n padding-left: ", ";\n padding-right: ", ";\n "], ["\n padding-left: ", ";\n padding-right: ", ";\n "])), t.sideMenuBackButtonIconPaddingLeft, t.sideMenuBackButtonIconPaddingRight);
|
|
29
35
|
},
|
|
30
36
|
});
|
|
31
37
|
});
|
|
32
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
|
|
38
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
|
|
@@ -2,6 +2,7 @@ import { useEmotion, useStyles } from '@skbkontur/react-ui/lib/renderEnvironment
|
|
|
2
2
|
import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
|
|
3
3
|
import React, { useContext } from 'react';
|
|
4
4
|
import { getSideMenuTheme } from '../../../lib/theming/ThemeHelpers.js';
|
|
5
|
+
import { SideMenuContext } from '../../SideMenuContext.js';
|
|
5
6
|
import { getStyles } from './Marker.styles.js';
|
|
6
7
|
export var Marker = function (_a) {
|
|
7
8
|
var _b;
|
|
@@ -10,12 +11,17 @@ export var Marker = function (_a) {
|
|
|
10
11
|
var styles = useStyles(getStyles);
|
|
11
12
|
var cx = useEmotion().cx;
|
|
12
13
|
var isEmpty = marker === true || marker === '';
|
|
14
|
+
var isLarge = useContext(SideMenuContext).size === 'large';
|
|
15
|
+
var isCollapsedItem = !_isSubMenu && isCollapsed;
|
|
13
16
|
return (React.createElement("span", { className: cx(styles.root(theme), (_b = {},
|
|
14
17
|
_b[styles.rootEmpty(theme)] = isEmpty,
|
|
15
18
|
_b[styles.rootMultiline(theme)] = isMultiline,
|
|
16
19
|
_b[styles.rootSubMenu(theme)] = _isSubMenu,
|
|
17
20
|
_b[styles.rootSubMenuEmpty(theme)] = _isSubMenu && isEmpty,
|
|
18
|
-
_b[styles.
|
|
19
|
-
_b[styles.
|
|
21
|
+
_b[styles.rootSubMenuLarge(theme)] = _isSubMenu && !isEmpty && isLarge,
|
|
22
|
+
_b[styles.rootCollapsed()] = isCollapsedItem,
|
|
23
|
+
_b[styles.rootCollapsedLarge()] = isCollapsedItem && isLarge,
|
|
24
|
+
_b[styles.rootEmptyCollapsed()] = isCollapsedItem && isEmpty,
|
|
25
|
+
_b[styles.rootEmptyCollapsedLarge()] = isCollapsedItem && isEmpty && isLarge,
|
|
20
26
|
_b)) }, marker));
|
|
21
27
|
};
|
|
@@ -5,6 +5,9 @@ export declare const getStyles: import("../../../lib/theming/ThemeHelpers.js").S
|
|
|
5
5
|
rootMultiline(t: SideMenuTheme): string;
|
|
6
6
|
rootSubMenu(t: SideMenuTheme): string;
|
|
7
7
|
rootSubMenuEmpty(t: SideMenuTheme): string;
|
|
8
|
+
rootSubMenuLarge(t: SideMenuTheme): string;
|
|
8
9
|
rootCollapsed(): string;
|
|
10
|
+
rootCollapsedLarge(): string;
|
|
9
11
|
rootEmptyCollapsed(): string;
|
|
12
|
+
rootEmptyCollapsedLarge(): string;
|
|
10
13
|
}>;
|
|
@@ -13,17 +13,28 @@ export var getStyles = memoizeGetStyles(function (_a) {
|
|
|
13
13
|
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n align-self: flex-start;\n margin-top: ", ";\n "], ["\n align-self: flex-start;\n margin-top: ", ";\n "])), t.sideMenuMarkerMultilineMarginTop);
|
|
14
14
|
},
|
|
15
15
|
rootSubMenu: function (t) {
|
|
16
|
-
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n background: transparent;\n color: ", ";\n font-weight: ", ";\n "], ["\n background: transparent;\n color: ", ";\n font-weight: ", ";\n "])), t.sideMenuMarkerSubItemColor, t.sideMenuMarkerSubItemFontWeight);
|
|
16
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n margin-right: ", ";\n background: transparent;\n color: ", ";\n font-weight: ", ";\n "], ["\n margin-right: ", ";\n background: transparent;\n color: ", ";\n font-weight: ", ";\n "])), t.sideMenuMarkerSubItemMarginRight, t.sideMenuMarkerSubItemColor, t.sideMenuMarkerSubItemFontWeight);
|
|
17
17
|
},
|
|
18
18
|
rootSubMenuEmpty: function (t) {
|
|
19
|
-
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n background: ", ";\n "], ["\n background: ", ";\n "])), t.sideMenuMarkerBg);
|
|
19
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n margin-right: ", ";\n background: ", ";\n "], ["\n margin-right: ", ";\n background: ", ";\n "])), t.sideMenuMarkerSubItemEmptyMarginRight, t.sideMenuMarkerBg);
|
|
20
20
|
},
|
|
21
|
+
rootSubMenuLarge: function (t) {
|
|
22
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-size: ", ";\n line-height: ", ";\n "])), t.sideMenuMarkerSubItemFontSizeLarge, t.sideMenuMarkerSubItemLineHeightLarge);
|
|
23
|
+
},
|
|
24
|
+
// В свёрнутом меню бейдж позиционируется относительно центра пункта (т.е. иконки),
|
|
25
|
+
// чтобы не отрываться от неё при любом размере пункта.
|
|
21
26
|
rootCollapsed: function () {
|
|
22
|
-
return css(
|
|
27
|
+
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n position: absolute;\n left: calc(50% + 13px);\n top: 0;\n transform: translateX(-50%);\n margin: 0;\n "], ["\n position: absolute;\n left: calc(50% + 13px);\n top: 0;\n transform: translateX(-50%);\n margin: 0;\n "])));
|
|
28
|
+
},
|
|
29
|
+
rootCollapsedLarge: function () {
|
|
30
|
+
return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n top: 3px;\n "], ["\n top: 3px;\n "])));
|
|
23
31
|
},
|
|
24
32
|
rootEmptyCollapsed: function () {
|
|
25
|
-
return css(
|
|
33
|
+
return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n left: calc(50% + 12px);\n top: 4px;\n "], ["\n left: calc(50% + 12px);\n top: 4px;\n "])));
|
|
34
|
+
},
|
|
35
|
+
rootEmptyCollapsedLarge: function () {
|
|
36
|
+
return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n top: 8px;\n "], ["\n top: 8px;\n "])));
|
|
26
37
|
},
|
|
27
38
|
});
|
|
28
39
|
});
|
|
29
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
40
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
|
|
@@ -9,8 +9,8 @@ import { getStyles as getSideMenuStyles } from '../SideMenu/SideMenu.styles.js';
|
|
|
9
9
|
import { SideMenuContext } from '../SideMenuContext.js';
|
|
10
10
|
import { getStyles as getDropdownStyles } from '../SideMenuDropdown/SideMenuDropdown.styles.js';
|
|
11
11
|
export var NarrowAccordionDropdown = function (_a) {
|
|
12
|
-
var _b;
|
|
13
|
-
var
|
|
12
|
+
var _b, _c;
|
|
13
|
+
var _d;
|
|
14
14
|
var caption = _a.caption, children = _a.children, htmlId = _a.htmlId, ariaLabel = _a["aria-label"], childIdCounterRef = _a.childIdCounterRef, disabled = _a.disabled, onOpenChange = _a.onOpenChange;
|
|
15
15
|
var context = useContext(SideMenuContext);
|
|
16
16
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
@@ -19,17 +19,17 @@ export var NarrowAccordionDropdown = function (_a) {
|
|
|
19
19
|
var dropdownStyles = useStyles(getDropdownStyles);
|
|
20
20
|
var dropdownMenuRef = useRef(null);
|
|
21
21
|
var isMenuCollapsed = !context.isOpened && (context.isDesktop || context.isNarrowDesktop);
|
|
22
|
-
return (React.createElement("div", { className: cx(dropdownStyles.wrapper()) },
|
|
23
|
-
React.createElement(DropdownMenu, { ref: dropdownMenuRef, caption: React.createElement("div", { className: cx(dropdownStyles.label(theme), (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
return (React.createElement("div", { className: cx(dropdownStyles.wrapper(), (_b = {}, _b[dropdownStyles.wrapperCollapsed()] = isMenuCollapsed, _b)) },
|
|
23
|
+
React.createElement(DropdownMenu, { ref: dropdownMenuRef, caption: React.createElement("div", { className: cx(dropdownStyles.label(theme), (_c = {},
|
|
24
|
+
_c[dropdownStyles.labelTouchScreen(theme)] = context.isTouchScreen,
|
|
25
|
+
_c[dropdownStyles.labelCollapsed()] = isMenuCollapsed,
|
|
26
|
+
_c)), onClick: disabled ? function (e) { return e.stopPropagation(); } : undefined }, caption), positions: ['right top', 'right middle', 'right bottom'], disableAnimations: true, popupMenuId: htmlId, "aria-label": ariaLabel, onOpen: function () {
|
|
27
27
|
if (childIdCounterRef) {
|
|
28
28
|
childIdCounterRef.current = 0;
|
|
29
29
|
}
|
|
30
30
|
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(true);
|
|
31
31
|
}, onClose: function () { return onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(false); } },
|
|
32
32
|
React.createElement("ul", { className: cx(sideMenuStyles.list()), "data-tid": SideMenuDataTids.narrowAccordionDropdown },
|
|
33
|
-
React.createElement(SideMenuContext.Provider, { value: __assign(__assign({}, context), { hasSeparatedSubMenu: false, parentItemId: htmlId, currentItemNestingLevel: ((
|
|
33
|
+
React.createElement(SideMenuContext.Provider, { value: __assign(__assign({}, context), { hasSeparatedSubMenu: false, parentItemId: htmlId, currentItemNestingLevel: ((_d = context.currentItemNestingLevel) !== null && _d !== void 0 ? _d : 0) + 1, closeParentDropdown: function () { var _a; return (_a = dropdownMenuRef.current) === null || _a === void 0 ? void 0 : _a.close(); }, childIdCounterRef: childIdCounterRef !== null && childIdCounterRef !== void 0 ? childIdCounterRef : context.childIdCounterRef }) }, children)))));
|
|
34
34
|
};
|
|
35
35
|
NarrowAccordionDropdown.displayName = 'NarrowAccordionDropdown';
|