@skbkontur/side-menu 4.0.10 → 5.0.0-alpha.1
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 +0 -15
- package/README.md +38 -11
- package/SideMenuDataTids.d.ts +2 -1
- package/SideMenuDataTids.js +2 -1
- package/hooks/useMemoIcon.d.ts +1 -2
- package/hooks/useMemoIcon.js +0 -9
- package/hooks/useNodeState.d.ts +7 -0
- package/hooks/useNodeState.js +12 -0
- package/hooks/useSideMenuReducer.d.ts +13 -0
- package/hooks/useSideMenuReducer.js +23 -0
- package/internal/themes/SideMenuDarkTheme.js +4 -0
- package/internal/themes/SideMenuTheme.d.ts +7 -7
- package/internal/themes/SideMenuTheme.js +9 -23
- package/lib/theming/ThemeHelpers.js +0 -4
- package/lib/utils/scripts.d.ts +1 -0
- package/lib/utils/scripts.js +9 -0
- package/package.json +1 -1
- package/src/SideMenu/SideMenu.d.ts +7 -4
- package/src/SideMenu/SideMenu.js +165 -179
- package/src/SideMenu/SideMenu.styles.d.ts +1 -0
- package/src/SideMenu/SideMenu.styles.js +12 -6
- package/src/SideMenuAvatar/SideMenuAvatar.js +7 -2
- package/src/SideMenuContext.d.ts +21 -9
- package/src/SideMenuContext.js +6 -1
- package/src/SideMenuDropdown/SideMenuDropdown.js +19 -19
- package/src/SideMenuDropdown/SideMenuDropdown.styles.js +9 -8
- package/src/SideMenuFooter/SideMenuFooter.js +21 -3
- package/src/SideMenuFooter/SideMenuFooter.styles.d.ts +4 -0
- package/src/SideMenuFooter/SideMenuFooter.styles.js +16 -4
- package/src/SideMenuHeader/SideMenuHeader.js +6 -5
- package/src/SideMenuNotifications/BellWidget.js +6 -13
- package/src/SideMenuNotifications/BellWidgetError.js +3 -6
- package/src/SideMenuNotifications/BellWidgetView.styles.d.ts +4 -7
- package/src/SideMenuNotifications/BellWidgetView.styles.js +9 -20
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.js +1 -0
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.d.ts +1 -0
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.js +5 -2
- package/src/SideMenuSubLink/SideMenuSubLink.d.ts +1 -1
- package/src/internal/BackButton.d.ts +1 -3
- package/src/internal/BackButton.js +4 -3
- package/src/internal/ClickableElement.d.ts +18 -2
- package/src/internal/ClickableElement.js +190 -69
- package/src/internal/ClickableElement.styles.d.ts +4 -0
- package/src/internal/ClickableElement.styles.js +19 -7
- package/src/internal/CollapseToggle.d.ts +2 -0
- package/src/internal/CollapseToggle.js +40 -0
- package/src/internal/{RightBorder.styles.d.ts → CollapseToggle.styles.d.ts} +0 -1
- package/src/internal/CollapseToggle.styles.js +13 -0
- package/src/internal/ItemContent/Caption.d.ts +1 -1
- package/src/internal/ItemContent/Caption.js +9 -26
- package/src/internal/ItemContent/Icon.js +3 -2
- package/src/internal/ItemContent/Icon.styles.d.ts +1 -0
- package/src/internal/ItemContent/Icon.styles.js +6 -3
- package/src/internal/ItemContent/ItemContent.js +17 -5
- package/src/internal/ItemContent/ItemContent.styles.d.ts +1 -0
- package/src/internal/ItemContent/ItemContent.styles.js +7 -4
- package/src/internal/NarrowAccordionDropdown.d.ts +15 -0
- package/src/internal/NarrowAccordionDropdown.js +35 -0
- package/src/internal/SeparatedSubMenu.js +7 -9
- package/src/internal/SeparatedSubMenu.styles.d.ts +0 -3
- package/src/internal/SeparatedSubMenu.styles.js +6 -15
- package/src/internal/SideMenuLogotype.js +13 -11
- package/src/internal/SubMenu.js +3 -2
- package/src/navigationAttributes.d.ts +3 -0
- package/src/navigationAttributes.js +3 -0
- package/src/state/reducer.d.ts +2 -0
- package/src/state/reducer.js +258 -0
- package/src/state/selectors.d.ts +16 -0
- package/src/state/selectors.js +71 -0
- package/src/state/types.d.ts +59 -0
- package/src/state/types.js +17 -0
- package/src/Navigation.d.ts +0 -53
- package/src/Navigation.js +0 -194
- package/src/SideMenuNotifications/utils/getWrapperHeightClass.d.ts +0 -11
- package/src/SideMenuNotifications/utils/getWrapperHeightClass.js +0 -10
- package/src/Tree.d.ts +0 -17
- package/src/Tree.js +0 -135
- package/src/internal/RightBorder.d.ts +0 -9
- package/src/internal/RightBorder.js +0 -37
- package/src/internal/RightBorder.styles.js +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -3,21 +3,6 @@
|
|
|
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
|
-
## [4.0.10](/compare/@skbkontur/side-menu@4.0.9...@skbkontur/side-menu@4.0.10) (2026-09-16)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### Bug Fixes
|
|
10
|
-
|
|
11
|
-
* **SideMenu:** fit BellWidget error layout on small screens fd17bcd
|
|
12
|
-
* **SideMenu:** fit BellWidget height to MobilePopup on mobile dd8c638
|
|
13
|
-
* **SideMenu:** show deprecation warning on sideMenuProductColor var customization a53a9b9
|
|
14
|
-
* **SideMenu:** use isMobile for BellWidget width 19a4233
|
|
15
|
-
* **SideMenu:** use shapeBoldWarning for BellWidgetError icons ee5f199
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
6
|
## [4.0.9](/compare/@skbkontur/side-menu@4.0.8...@skbkontur/side-menu@4.0.9) (2026-07-23)
|
|
22
7
|
|
|
23
8
|
|
package/README.md
CHANGED
|
@@ -559,30 +559,53 @@ const [isOpen, setIsOpen] = React.useState(true);
|
|
|
559
559
|
</div>
|
|
560
560
|
```
|
|
561
561
|
|
|
562
|
-
|
|
562
|
+
> На широких экранах меню сворачивается и разворачивается кнопкой-переключателем в футере (`CollapseToggle`).
|
|
563
|
+
> Управлять состоянием можно через пропы `isOpen` / `onOpen` / `onClose` (см. пример выше).
|
|
564
|
+
>
|
|
565
|
+
> Пропы `isPinned` и `onPinnedValueChange` устарели — используйте `isOpen` и `onClose`.
|
|
566
|
+
|
|
567
|
+
#### Пример с сохранением состояния меню (`isOpen` + `localStorage`)
|
|
563
568
|
|
|
564
569
|
```jsx harmony
|
|
565
570
|
import { CdnLogo } from '@skbkontur/ui-cdn-components';
|
|
566
571
|
import { SideMenu } from '@skbkontur/side-menu';
|
|
567
572
|
import { IconDocTextRegular24 } from '@skbkontur/icons/IconDocTextRegular24';
|
|
568
573
|
import { IconSettingsGearRegular24 } from '@skbkontur/icons/IconSettingsGearRegular24';
|
|
569
|
-
import { ThemeContext, ThemeFactory
|
|
574
|
+
import { ThemeContext, ThemeFactory } from '@skbkontur/react-ui';
|
|
575
|
+
|
|
576
|
+
const readIsOpen = () => {
|
|
577
|
+
try {
|
|
578
|
+
return localStorage.getItem('sideMenuIsOpen') !== 'false';
|
|
579
|
+
} catch {
|
|
580
|
+
return true;
|
|
581
|
+
}
|
|
582
|
+
};
|
|
570
583
|
|
|
571
|
-
const
|
|
584
|
+
const writeIsOpen = (value) => {
|
|
585
|
+
try {
|
|
586
|
+
localStorage.setItem('sideMenuIsOpen', String(value));
|
|
587
|
+
} catch {
|
|
588
|
+
/* localStorage может быть недоступен (приватный режим, отключено) */
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
|
|
592
|
+
const [isOpen, setIsOpen] = React.useState(readIsOpen());
|
|
572
593
|
|
|
573
594
|
React.useEffect(() => {
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
595
|
+
const sync = () => setIsOpen(readIsOpen());
|
|
596
|
+
window.addEventListener('storage', sync);
|
|
597
|
+
return () => window.removeEventListener('storage', sync);
|
|
577
598
|
}, []);
|
|
578
599
|
|
|
600
|
+
const persist = (value) => {
|
|
601
|
+
setIsOpen(value);
|
|
602
|
+
writeIsOpen(value);
|
|
603
|
+
};
|
|
604
|
+
|
|
579
605
|
<div style={{ height: '200px', position: 'relative', display: 'flex' }}>
|
|
580
606
|
<ThemeContext.Provider
|
|
581
607
|
value={ThemeFactory.create({ sideMenuWidth: '300px', sideMenuProductColor: '#64b419' })}>
|
|
582
|
-
<SideMenu
|
|
583
|
-
onPinnedValueChange={(isPinned) => {
|
|
584
|
-
localStorage.setItem('sideMenuIsPinned', String(isPinned));
|
|
585
|
-
}}>
|
|
608
|
+
<SideMenu isOpen={isOpen} onOpen={() => persist(true)} onClose={() => persist(false)}>
|
|
586
609
|
<SideMenu.Header productLogo={<CdnLogo logo="ofd" />} />
|
|
587
610
|
<SideMenu.Body>
|
|
588
611
|
<SideMenu.Item icon={<IconDocTextRegular24 />} caption={'Документы к подписанию'} />
|
|
@@ -626,10 +649,14 @@ React.useEffect(() => {
|
|
|
626
649
|
//#region NestedMenu
|
|
627
650
|
sideMenuNestedMenuPaddingLeft: string;
|
|
628
651
|
//#endregion
|
|
652
|
+
//#region CollapseToggle (для широких экранов)
|
|
653
|
+
sideMenuCollapseToggleSize: string;
|
|
654
|
+
sideMenuCollapseToggleSizeLarge: string;
|
|
655
|
+
//#endregion
|
|
629
656
|
//#region RightBorder
|
|
630
657
|
sideMenuRightBorderWidth: string;
|
|
631
658
|
sideMenuRightBorderIconColor: string;
|
|
632
|
-
|
|
659
|
+
sideMenuRightBorderIconColorHover: string;
|
|
633
660
|
// #region BackButton (for Mobiles)
|
|
634
661
|
sideMenuBackButtonCaptionFontWeight: string;
|
|
635
662
|
sideMenuBackButtonCaptionFontSize: string;
|
package/SideMenuDataTids.d.ts
CHANGED
|
@@ -3,9 +3,10 @@ export declare const SideMenuDataTids: {
|
|
|
3
3
|
burger: string;
|
|
4
4
|
backButton: string;
|
|
5
5
|
separatedSubMenu: string;
|
|
6
|
-
rightBorder: string;
|
|
7
6
|
clickableElement: string;
|
|
8
7
|
footer: string;
|
|
8
|
+
collapseToggle: string;
|
|
9
|
+
narrowAccordionDropdown: string;
|
|
9
10
|
bellSideMenuDropdownButton: string;
|
|
10
11
|
bellCloseButton: string;
|
|
11
12
|
bellHeader: string;
|
package/SideMenuDataTids.js
CHANGED
|
@@ -3,9 +3,10 @@ export var SideMenuDataTids = {
|
|
|
3
3
|
burger: 'SideMenu__burger',
|
|
4
4
|
backButton: 'SideMenu__backButton',
|
|
5
5
|
separatedSubMenu: 'SideMenu__separatedSubMenu',
|
|
6
|
-
rightBorder: 'SideMenu__rightBorder',
|
|
7
6
|
clickableElement: 'SideMenu__clickableElement',
|
|
8
7
|
footer: 'SideMenu__footer',
|
|
8
|
+
collapseToggle: 'SideMenu__collapseToggle',
|
|
9
|
+
narrowAccordionDropdown: 'SideMenu__narrowAccordionDropdown',
|
|
9
10
|
bellSideMenuDropdownButton: 'SideMenu__bellDropdownButton',
|
|
10
11
|
bellCloseButton: 'SideMenu__bellCloseButton',
|
|
11
12
|
bellHeader: 'SideMenu__bellHeaderWidget',
|
package/hooks/useMemoIcon.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
interface IconParams {
|
|
3
3
|
isOpened: boolean;
|
|
4
|
-
onClick: () => void;
|
|
4
|
+
onClick: (e: React.MouseEvent) => void;
|
|
5
5
|
}
|
|
6
6
|
export declare const useMemoIcon: (children: React.ReactNode, { isOpened, onClick }: IconParams) => JSX.Element | undefined;
|
|
7
|
-
export declare const useMemoBorderIcon: (isCollapsed?: boolean) => JSX.Element;
|
|
8
7
|
export {};
|
package/hooks/useMemoIcon.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IconArrowCDownRegular16 } from '@skbkontur/icons/IconArrowCDownRegular16';
|
|
2
|
-
import { IconArrowCLeftRegular16 } from '@skbkontur/icons/IconArrowCLeftRegular16';
|
|
3
2
|
import { IconArrowCRightRegular16 } from '@skbkontur/icons/IconArrowCRightRegular16';
|
|
4
3
|
import React, { useMemo } from 'react';
|
|
5
4
|
export var useMemoIcon = function (children, _a) {
|
|
@@ -13,11 +12,3 @@ export var useMemoIcon = function (children, _a) {
|
|
|
13
12
|
}
|
|
14
13
|
}, [isOpened, children]);
|
|
15
14
|
};
|
|
16
|
-
export var useMemoBorderIcon = function (isCollapsed) {
|
|
17
|
-
return useMemo(function () {
|
|
18
|
-
if (isCollapsed) {
|
|
19
|
-
return React.createElement(IconArrowCRightRegular16, null);
|
|
20
|
-
}
|
|
21
|
-
return React.createElement(IconArrowCLeftRegular16, null);
|
|
22
|
-
}, [isCollapsed]);
|
|
23
|
-
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { SideMenuContext } from '../src/SideMenuContext.js';
|
|
3
|
+
import { hasSeparatedSubMenu, isActive, isExpanded, isNestedSubMenu } from '../src/state/selectors.js';
|
|
4
|
+
export function useNodeState(id) {
|
|
5
|
+
var state = useContext(SideMenuContext).state;
|
|
6
|
+
return {
|
|
7
|
+
isActive: isActive(state, id),
|
|
8
|
+
isExpanded: isExpanded(state, id),
|
|
9
|
+
isNestedSubMenu: isNestedSubMenu(state, id),
|
|
10
|
+
hasSeparatedSubMenu: hasSeparatedSubMenu(state, id),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Dispatch } from 'react';
|
|
2
|
+
import { type Action, type SideMenuState, type Viewport } from '../src/state/types.js';
|
|
3
|
+
export interface UseSideMenuReducerOptions {
|
|
4
|
+
activeItem?: string;
|
|
5
|
+
isSeparatedMenu: boolean;
|
|
6
|
+
viewport: Viewport;
|
|
7
|
+
isOpened: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface UseSideMenuReducerResult {
|
|
10
|
+
state: SideMenuState;
|
|
11
|
+
dispatch: Dispatch<Action>;
|
|
12
|
+
}
|
|
13
|
+
export declare function useSideMenuReducer(options: UseSideMenuReducerOptions): UseSideMenuReducerResult;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { __read } from "tslib";
|
|
2
|
+
import { useEffect, useReducer } from 'react';
|
|
3
|
+
import { sideMenuReducer } from '../src/state/reducer.js';
|
|
4
|
+
import { createInitialState } from '../src/state/types.js';
|
|
5
|
+
export function useSideMenuReducer(options) {
|
|
6
|
+
var _a = __read(useReducer(sideMenuReducer, undefined, createInitialState), 2), state = _a[0], dispatch = _a[1];
|
|
7
|
+
useEffect(function () {
|
|
8
|
+
dispatch({ type: 'SET_VIEWPORT', viewport: options.viewport });
|
|
9
|
+
}, [options.viewport]);
|
|
10
|
+
useEffect(function () {
|
|
11
|
+
dispatch({ type: 'SET_OPENED', open: options.isOpened });
|
|
12
|
+
}, [options.isOpened]);
|
|
13
|
+
useEffect(function () {
|
|
14
|
+
dispatch({ type: 'SET_SEPARATED_MENU', isSeparatedMenu: options.isSeparatedMenu });
|
|
15
|
+
}, [options.isSeparatedMenu]);
|
|
16
|
+
// The reducer defers an `activeItem` that names a not-yet-registered node and applies it
|
|
17
|
+
// on REGISTER, so this effect only needs to react to the prop itself.
|
|
18
|
+
useEffect(function () {
|
|
19
|
+
var _a;
|
|
20
|
+
dispatch({ type: 'SET_ACTIVE_ITEM', id: (_a = options.activeItem) !== null && _a !== void 0 ? _a : null });
|
|
21
|
+
}, [options.activeItem]);
|
|
22
|
+
return { state: state, dispatch: dispatch };
|
|
23
|
+
}
|
|
@@ -10,6 +10,7 @@ var SideMenuDarkTheme = /** @class */ (function (_super) {
|
|
|
10
10
|
// #region SideMenu
|
|
11
11
|
SideMenuDarkTheme.sideMenuBg = colors.surfaceLow;
|
|
12
12
|
SideMenuDarkTheme.sideMenuBgHover = colors.shapeOtherNeutralFaintSolid;
|
|
13
|
+
SideMenuDarkTheme.sideMenuBgPressed = colors.shapeOtherNeutralFaintSolidPressed;
|
|
13
14
|
// #endregion
|
|
14
15
|
// #region Divider
|
|
15
16
|
SideMenuDarkTheme.sideMenuDividerBg = colors.lineNeutralFaint;
|
|
@@ -17,11 +18,14 @@ var SideMenuDarkTheme = /** @class */ (function (_super) {
|
|
|
17
18
|
// #region Item
|
|
18
19
|
SideMenuDarkTheme.sideMenuItemBgHover = colors.shapeOtherBacklessHover;
|
|
19
20
|
SideMenuDarkTheme.sideMenuItemBgActive = colors.shapeOtherBase;
|
|
21
|
+
SideMenuDarkTheme.sideMenuItemBgActivePressed = colors.shapeOtherBasePressed;
|
|
22
|
+
SideMenuDarkTheme.sideMenuItemBgPressed = colors.shapeOtherBacklessPressed;
|
|
20
23
|
SideMenuDarkTheme.sideMenuItemColor = colors.textNeutralHeavy;
|
|
21
24
|
SideMenuDarkTheme.sideMenuItemColorDisabled = colors.textNeutralFaint;
|
|
22
25
|
SideMenuDarkTheme.sideMenuItemBoxShadowColorFocus = colors.lineAccentBold;
|
|
23
26
|
SideMenuDarkTheme.sideMenuSubItemWithSeparatedSubMenuBgHover = colors.shapeOtherBacklessHover;
|
|
24
27
|
SideMenuDarkTheme.sideMenuSubItemWithSeparatedSubMenuBgActive = colors.shapeFaintNeutralAlpha;
|
|
28
|
+
SideMenuDarkTheme.sideMenuSubItemWithSeparatedSubMenuBgPressed = colors.shapeFaintNeutralAlphaPressed;
|
|
25
29
|
// #endregion
|
|
26
30
|
// #region Icon
|
|
27
31
|
SideMenuDarkTheme.sideMenuIconSubItemColor = colors.textNeutralSoft;
|
|
@@ -7,6 +7,7 @@ export declare class SideMenuTheme extends BasicThemeClassForExtension {
|
|
|
7
7
|
static sideMenuMarginX: string;
|
|
8
8
|
static sideMenuBg: string;
|
|
9
9
|
static sideMenuBgHover: string;
|
|
10
|
+
static sideMenuBgPressed: string;
|
|
10
11
|
static sideMenuBoxShadow: string;
|
|
11
12
|
static sideMenuLineHeight: string;
|
|
12
13
|
static sideMenuLineHeightLarge: string;
|
|
@@ -35,9 +36,12 @@ export declare class SideMenuTheme extends BasicThemeClassForExtension {
|
|
|
35
36
|
static sideMenuFooterPaddingTop: string;
|
|
36
37
|
static sideMenuFooterPaddingBottom: string;
|
|
37
38
|
static get sideMenuFooterDividerColor(): string;
|
|
39
|
+
static sideMenuCollapseToggleSize: string;
|
|
38
40
|
static sideMenuItemBorderRadius: string;
|
|
39
41
|
static sideMenuItemBgHover: string;
|
|
40
42
|
static sideMenuItemBgActive: string;
|
|
43
|
+
static sideMenuItemBgActivePressed: string;
|
|
44
|
+
static sideMenuItemBgPressed: string;
|
|
41
45
|
static sideMenuItemColor: string;
|
|
42
46
|
static sideMenuItemColorDisabled: string;
|
|
43
47
|
static sideMenuItemBoxShadowColorFocus: string;
|
|
@@ -45,6 +49,7 @@ export declare class SideMenuTheme extends BasicThemeClassForExtension {
|
|
|
45
49
|
static sideMenuItemNestedPaddingLeft: string;
|
|
46
50
|
static sideMenuSubItemWithSeparatedSubMenuBgHover: string;
|
|
47
51
|
static sideMenuSubItemWithSeparatedSubMenuBgActive: string;
|
|
52
|
+
static sideMenuSubItemWithSeparatedSubMenuBgPressed: string;
|
|
48
53
|
static sideMenuItemContentPaddingY: string;
|
|
49
54
|
static sideMenuItemContentPaddingYLarge: string;
|
|
50
55
|
static sideMenuItemContentPaddingYTouchScreen: string;
|
|
@@ -55,6 +60,8 @@ export declare class SideMenuTheme extends BasicThemeClassForExtension {
|
|
|
55
60
|
static sideMenuSubItemContentPaddingY: string;
|
|
56
61
|
static sideMenuSubItemContentPaddingYLarge: string;
|
|
57
62
|
static sideMenuSubItemContentPaddingYTouchScreen: string;
|
|
63
|
+
static sideMenuSubItemContentPaddingYDropdown: string;
|
|
64
|
+
static sideMenuSubItemContentPaddingXDropdown: string;
|
|
58
65
|
static sideMenuIconSize: string;
|
|
59
66
|
static sideMenuIconMarginY: string;
|
|
60
67
|
static sideMenuIconMarginX: string;
|
|
@@ -122,13 +129,6 @@ export declare class SideMenuTheme extends BasicThemeClassForExtension {
|
|
|
122
129
|
static sideMenuNotificationsMarkerBg: string;
|
|
123
130
|
/** от 400px до 784px */
|
|
124
131
|
static sideMenuNotificationsWrapperHeight: string;
|
|
125
|
-
/**
|
|
126
|
-
* CSS-выражение для вычитания из 100vh на mobile (отступы MobilePopup `@skbkontur/react-ui`).
|
|
127
|
-
*
|
|
128
|
-
* Тема < 6.1: `2 * mobilePopupTopPadding`.
|
|
129
|
-
* Тема ≥ 6.1: `2 * mobilePopupPositionY + 2 * mobilePopupPaddingSmall` (size small).
|
|
130
|
-
*/
|
|
131
|
-
static get sideMenuNotificationsMobilePopupHeightOffset(): string;
|
|
132
132
|
}
|
|
133
133
|
export declare const REACT_UI_SIDE_MENU_THEME_KEY = "__IS_REACT_UI_SIDE_MENU_THEME__";
|
|
134
134
|
export declare const markAsSideMenuTheme: <T extends object>(theme: T) => T;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __extends } from "tslib";
|
|
2
2
|
import * as colors from '@skbkontur/colors/tokens-default/light';
|
|
3
3
|
import { BasicThemeClassForExtension } from '@skbkontur/react-ui/internal/themes/BasicTheme';
|
|
4
|
-
import { exposeGetters
|
|
4
|
+
import { exposeGetters } from '@skbkontur/react-ui/lib/theming/ThemeHelpers';
|
|
5
5
|
import warning from 'warning';
|
|
6
6
|
var SideMenuTheme = /** @class */ (function (_super) {
|
|
7
7
|
__extends(SideMenuTheme, _super);
|
|
@@ -15,7 +15,7 @@ var SideMenuTheme = /** @class */ (function (_super) {
|
|
|
15
15
|
return this._sideMenuProductColor;
|
|
16
16
|
},
|
|
17
17
|
set: function (value) {
|
|
18
|
-
warning(
|
|
18
|
+
warning('[SideMenuTheme]: sideMenuProductColor is deprecated. Use @skbkontur/colors or theme variable `sideMenuMarkerBg` instead');
|
|
19
19
|
this._sideMenuProductColor = value;
|
|
20
20
|
},
|
|
21
21
|
enumerable: false,
|
|
@@ -91,27 +91,6 @@ var SideMenuTheme = /** @class */ (function (_super) {
|
|
|
91
91
|
enumerable: false,
|
|
92
92
|
configurable: true
|
|
93
93
|
});
|
|
94
|
-
Object.defineProperty(SideMenuTheme, "sideMenuNotificationsMobilePopupHeightOffset", {
|
|
95
|
-
/**
|
|
96
|
-
* CSS-выражение для вычитания из 100vh на mobile (отступы MobilePopup `@skbkontur/react-ui`).
|
|
97
|
-
*
|
|
98
|
-
* Тема < 6.1: `2 * mobilePopupTopPadding`.
|
|
99
|
-
* Тема ≥ 6.1: `2 * mobilePopupPositionY + 2 * mobilePopupPaddingSmall` (size small).
|
|
100
|
-
*/
|
|
101
|
-
get: function () {
|
|
102
|
-
var _a, _b;
|
|
103
|
-
if (isThemeGTE(this, '6.1')) {
|
|
104
|
-
var theme = this;
|
|
105
|
-
var positionY = (_a = theme.mobilePopupPositionY) !== null && _a !== void 0 ? _a : '16px';
|
|
106
|
-
var paddingSmall = (_b = theme.mobilePopupPaddingSmall) !== null && _b !== void 0 ? _b : '6px';
|
|
107
|
-
// Внешние скобки обязательны: иначе в `calc(100vh - A + B)` B прибавится, а не вычтется.
|
|
108
|
-
return "((2 * ".concat(positionY, ") + (2 * ").concat(paddingSmall, "))");
|
|
109
|
-
}
|
|
110
|
-
return "(2 * ".concat(this.mobilePopupTopPadding, ")");
|
|
111
|
-
},
|
|
112
|
-
enumerable: false,
|
|
113
|
-
configurable: true
|
|
114
|
-
});
|
|
115
94
|
// #region SideMenu
|
|
116
95
|
SideMenuTheme.sideMenuWidth = '232px';
|
|
117
96
|
SideMenuTheme.sideMenuWidthTouchScreen = '328px';
|
|
@@ -119,6 +98,7 @@ var SideMenuTheme = /** @class */ (function (_super) {
|
|
|
119
98
|
SideMenuTheme.sideMenuMarginX = '16px';
|
|
120
99
|
SideMenuTheme.sideMenuBg = colors.surfaceLow;
|
|
121
100
|
SideMenuTheme.sideMenuBgHover = colors.shapeOtherNeutralFaintSolid;
|
|
101
|
+
SideMenuTheme.sideMenuBgPressed = colors.shapeOtherNeutralFaintSolidPressed;
|
|
122
102
|
SideMenuTheme.sideMenuBoxShadow = "\n 4px 0 12px rgba(0, 0, 0, 0.08),\n 12px 0 32px rgba(0, 0, 0, 0.04),\n 16px 0 40px rgba(0, 0, 0, 0.04)\n ";
|
|
123
103
|
SideMenuTheme.sideMenuLineHeight = '20px';
|
|
124
104
|
SideMenuTheme.sideMenuLineHeightLarge = '22px';
|
|
@@ -151,17 +131,21 @@ var SideMenuTheme = /** @class */ (function (_super) {
|
|
|
151
131
|
// #region Footer
|
|
152
132
|
SideMenuTheme.sideMenuFooterPaddingTop = '8px';
|
|
153
133
|
SideMenuTheme.sideMenuFooterPaddingBottom = '24px';
|
|
134
|
+
SideMenuTheme.sideMenuCollapseToggleSize = '40px';
|
|
154
135
|
// #endregion
|
|
155
136
|
// #region Item
|
|
156
137
|
SideMenuTheme.sideMenuItemBorderRadius = '8px';
|
|
157
138
|
SideMenuTheme.sideMenuItemBgHover = colors.shapeOtherBacklessHover;
|
|
158
139
|
SideMenuTheme.sideMenuItemBgActive = colors.shapeOtherBase;
|
|
140
|
+
SideMenuTheme.sideMenuItemBgActivePressed = colors.shapeOtherBasePressed;
|
|
141
|
+
SideMenuTheme.sideMenuItemBgPressed = colors.shapeOtherBacklessPressed;
|
|
159
142
|
SideMenuTheme.sideMenuItemColor = colors.textNeutralHeavy;
|
|
160
143
|
SideMenuTheme.sideMenuItemColorDisabled = colors.textNeutralFaint;
|
|
161
144
|
SideMenuTheme.sideMenuItemBoxShadowColorFocus = colors.lineAccentBold;
|
|
162
145
|
SideMenuTheme.sideMenuItemNestedPaddingLeft = '16px';
|
|
163
146
|
SideMenuTheme.sideMenuSubItemWithSeparatedSubMenuBgHover = colors.shapeOtherBacklessHover;
|
|
164
147
|
SideMenuTheme.sideMenuSubItemWithSeparatedSubMenuBgActive = colors.shapeFaintNeutralAlpha;
|
|
148
|
+
SideMenuTheme.sideMenuSubItemWithSeparatedSubMenuBgPressed = colors.shapeFaintNeutralAlphaPressed;
|
|
165
149
|
// #endregion
|
|
166
150
|
// #region ItemContent
|
|
167
151
|
SideMenuTheme.sideMenuItemContentPaddingY = '4px';
|
|
@@ -174,6 +158,8 @@ var SideMenuTheme = /** @class */ (function (_super) {
|
|
|
174
158
|
SideMenuTheme.sideMenuSubItemContentPaddingY = '4px';
|
|
175
159
|
SideMenuTheme.sideMenuSubItemContentPaddingYLarge = '5px';
|
|
176
160
|
SideMenuTheme.sideMenuSubItemContentPaddingYTouchScreen = '9px';
|
|
161
|
+
SideMenuTheme.sideMenuSubItemContentPaddingYDropdown = '6px';
|
|
162
|
+
SideMenuTheme.sideMenuSubItemContentPaddingXDropdown = '8px';
|
|
177
163
|
// #endregion
|
|
178
164
|
// #region Icon
|
|
179
165
|
SideMenuTheme.sideMenuIconSize = '24';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { __values } from "tslib";
|
|
2
2
|
import { isDarkTheme } from '@skbkontur/react-ui/lib/theming/ThemeHelpers';
|
|
3
3
|
import { isFunction } from '@skbkontur/react-ui/lib/utils';
|
|
4
|
-
import warning from 'warning';
|
|
5
4
|
import { SideMenuDarkThemeInternal } from '../../internal/themes/SideMenuDarkTheme.js';
|
|
6
5
|
import { SideMenuThemeInternal, isSideMenuTheme, markAsSideMenuTheme } from '../../internal/themes/SideMenuTheme.js';
|
|
7
6
|
import { memo } from '../utils/memo.js';
|
|
@@ -20,9 +19,6 @@ export var createSideMenuTheme = function (theme) {
|
|
|
20
19
|
if (isSideMenuTheme(theme)) {
|
|
21
20
|
return theme;
|
|
22
21
|
}
|
|
23
|
-
if (Object.prototype.hasOwnProperty.call(theme, 'sideMenuProductColor')) {
|
|
24
|
-
warning(false, '[SideMenuTheme]: sideMenuProductColor is deprecated. Use @skbkontur/colors or theme variable `sideMenuMarkerBg` instead');
|
|
25
|
-
}
|
|
26
22
|
var sideMenuTheme = Object.create(theme, Object.assign(Object.getOwnPropertyDescriptors(SideMenuThemeInternal), isDarkTheme(theme) ? Object.getOwnPropertyDescriptors(SideMenuDarkThemeInternal) : {}));
|
|
27
23
|
var _loop_1 = function (key) {
|
|
28
24
|
var descriptor = Object.getOwnPropertyDescriptor(sideMenuTheme, key);
|
package/lib/utils/scripts.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export declare const isBrowser: boolean;
|
|
|
3
3
|
export declare const isTouchDevice: () => boolean;
|
|
4
4
|
export declare const isKonturIcon: (icon: React.ReactElement) => boolean;
|
|
5
5
|
export declare const generateId: () => string;
|
|
6
|
+
export declare const flattenChildren: (children: React.ReactNode) => React.ReactNode[];
|
package/lib/utils/scripts.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Children, isValidElement, Fragment } from 'react';
|
|
1
2
|
export var isBrowser = typeof window !== 'undefined';
|
|
2
3
|
export var isTouchDevice = function () {
|
|
3
4
|
return isBrowser && ('ontouchstart' in window || matchMedia('(pointer: coarse)').matches);
|
|
@@ -8,3 +9,11 @@ export var isKonturIcon = function (icon) {
|
|
|
8
9
|
export var generateId = function () {
|
|
9
10
|
return Date.now().toString(36) + Math.random().toString(36).substr(2);
|
|
10
11
|
};
|
|
12
|
+
export var flattenChildren = function (children) {
|
|
13
|
+
return Children.toArray(children).flatMap(function (child) {
|
|
14
|
+
if (isValidElement(child) && child.type === Fragment) {
|
|
15
|
+
return flattenChildren(child.props.children);
|
|
16
|
+
}
|
|
17
|
+
return [child];
|
|
18
|
+
});
|
|
19
|
+
};
|
package/package.json
CHANGED
|
@@ -25,15 +25,18 @@ export interface SideMenuProps extends CommonProps {
|
|
|
25
25
|
*/
|
|
26
26
|
isSeparatedMenu?: boolean;
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* Проп для закрепленного состояния (работает только на широких экранах)
|
|
29
|
+
* @deprecated Используйте isOpen
|
|
29
30
|
*/
|
|
30
31
|
isPinned?: boolean;
|
|
31
32
|
/**
|
|
32
|
-
*
|
|
33
|
+
* Коллбэк для закрепленного состояния (работает только на широких экранах)
|
|
34
|
+
* @deprecated Используйте onClose
|
|
33
35
|
*/
|
|
34
36
|
onPinnedValueChange?: (isPinned: boolean) => void;
|
|
35
37
|
/**
|
|
36
|
-
*
|
|
38
|
+
* Заблокировать ручное сворачивание меню: скрывает кнопку-переключатель
|
|
39
|
+
* в футере. Автоматическое поведение при смене разрешения сохраняется.
|
|
37
40
|
*/
|
|
38
41
|
disableCollapsing?: boolean;
|
|
39
42
|
/**
|
|
@@ -95,7 +98,7 @@ interface SubComponents {
|
|
|
95
98
|
SubLink: typeof SideMenuSubLink;
|
|
96
99
|
__KONTUR_REACT_UI__: string;
|
|
97
100
|
}
|
|
98
|
-
export declare const transitionDuration =
|
|
101
|
+
export declare const transitionDuration = 200;
|
|
99
102
|
export declare const burgerTransitionDuration: number;
|
|
100
103
|
export declare const SideMenu: React.ForwardRefExoticComponent<SideMenuProps & React.RefAttributes<HTMLElement>> & SubComponents;
|
|
101
104
|
export {};
|