@skbkontur/side-menu 0.9.5 → 0.10.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.
Files changed (86) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +90 -9
  3. package/hooks/useActiveState.js +1 -1
  4. package/hooks/useNumberOfTextLinesInItem.d.ts +12 -1
  5. package/hooks/useNumberOfTextLinesInItem.js +45 -30
  6. package/hooks/useNumberOfTextLinesInSubItem.d.ts +2 -1
  7. package/hooks/useNumberOfTextLinesInSubItem.js +2 -2
  8. package/hooks/useOpenedState.js +1 -1
  9. package/hooks/useOpenedSubElementState.js +1 -1
  10. package/internal/themes/SideMenuTheme.d.ts +110 -0
  11. package/internal/themes/SideMenuTheme.js +234 -0
  12. package/lib/theming/ThemeHelpers.d.ts +18 -0
  13. package/lib/theming/ThemeHelpers.js +66 -0
  14. package/lib/theming/ThemeTypes.d.ts +3 -0
  15. package/lib/theming/ThemeTypes.js +0 -0
  16. package/lib/utils/memo.d.ts +1 -0
  17. package/lib/utils/memo.js +9 -0
  18. package/{utils → lib/utils}/scripts.d.ts +1 -2
  19. package/{utils → lib/utils}/scripts.js +0 -8
  20. package/package.json +2 -2
  21. package/src/SideMenu/SideMenu.js +40 -36
  22. package/src/SideMenu/SideMenu.styles.d.ts +12 -14
  23. package/src/SideMenu/SideMenu.styles.js +29 -31
  24. package/src/SideMenuAvatar/SideMenuAvatar.md +7 -0
  25. package/src/SideMenuBody/SideMenuBody.d.ts +1 -2
  26. package/src/SideMenuBody/SideMenuBody.js +16 -9
  27. package/src/SideMenuBody/SideMenuBody.md +7 -0
  28. package/src/SideMenuBody/SideMenuBody.styles.d.ts +2 -1
  29. package/src/SideMenuBody/SideMenuBody.styles.js +4 -4
  30. package/src/SideMenuContext.d.ts +3 -2
  31. package/src/SideMenuDivider/SideMenuDivider.md +7 -0
  32. package/src/SideMenuDivider/SideMenuDivider.styles.js +2 -1
  33. package/src/SideMenuDropdown/SideMenuDropdown.js +9 -8
  34. package/src/SideMenuDropdown/SideMenuDropdown.styles.d.ts +2 -1
  35. package/src/SideMenuDropdown/SideMenuDropdown.styles.js +4 -3
  36. package/src/SideMenuFooter/SideMenuFooter.js +6 -3
  37. package/src/SideMenuFooter/SideMenuFooter.md +8 -0
  38. package/src/SideMenuFooter/SideMenuFooter.styles.d.ts +3 -2
  39. package/src/SideMenuFooter/SideMenuFooter.styles.js +6 -6
  40. package/src/SideMenuHeader/SideMenuHeader.js +15 -6
  41. package/src/SideMenuHeader/SideMenuHeader.md +16 -0
  42. package/src/SideMenuHeader/SideMenuHeader.styles.d.ts +5 -5
  43. package/src/SideMenuHeader/SideMenuHeader.styles.js +12 -15
  44. package/src/SideMenuItem/SideMenuItem.md +63 -0
  45. package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.js +7 -1
  46. package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.md +7 -0
  47. package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.d.ts +2 -1
  48. package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.js +4 -3
  49. package/src/internal/Backdrop.styles.js +1 -1
  50. package/src/internal/Burger.js +4 -1
  51. package/src/internal/Burger.styles.d.ts +2 -1
  52. package/src/internal/Burger.styles.js +4 -3
  53. package/src/internal/ClickableElement.js +8 -5
  54. package/src/internal/ClickableElement.styles.d.ts +6 -5
  55. package/src/internal/ClickableElement.styles.js +13 -11
  56. package/src/internal/InnerBody.js +5 -2
  57. package/src/internal/InnerBody.styles.d.ts +2 -1
  58. package/src/internal/InnerBody.styles.js +4 -3
  59. package/src/internal/InnerSubMenu.js +1 -1
  60. package/src/internal/ItemContent/Avatar.js +5 -2
  61. package/src/internal/ItemContent/Avatar.styles.d.ts +2 -1
  62. package/src/internal/ItemContent/Avatar.styles.js +4 -3
  63. package/src/internal/ItemContent/Caption.js +9 -6
  64. package/src/internal/ItemContent/Caption.styles.d.ts +9 -6
  65. package/src/internal/ItemContent/Caption.styles.js +17 -14
  66. package/src/internal/ItemContent/Icon.js +19 -9
  67. package/src/internal/ItemContent/Icon.styles.d.ts +7 -6
  68. package/src/internal/ItemContent/Icon.styles.js +14 -13
  69. package/src/internal/ItemContent/ItemContent.js +36 -12
  70. package/src/internal/ItemContent/ItemContent.styles.d.ts +9 -9
  71. package/src/internal/ItemContent/ItemContent.styles.js +18 -22
  72. package/src/internal/ItemContent/Marker.js +6 -3
  73. package/src/internal/ItemContent/Marker.styles.d.ts +3 -2
  74. package/src/internal/ItemContent/Marker.styles.js +6 -5
  75. package/src/internal/NestedMenu.js +6 -3
  76. package/src/internal/NestedMenu.styles.d.ts +2 -1
  77. package/src/internal/NestedMenu.styles.js +4 -3
  78. package/src/internal/RightBorder.js +10 -9
  79. package/src/internal/RightBorder.styles.d.ts +3 -4
  80. package/src/internal/RightBorder.styles.js +7 -7
  81. package/src/internal/SeparatedSubMenu.js +13 -10
  82. package/src/internal/SeparatedSubMenu.styles.d.ts +9 -6
  83. package/src/internal/SeparatedSubMenu.styles.js +18 -17
  84. package/src/internal/SideMenuLogotype.js +14 -10
  85. package/src/internal/SideMenuLogotype.styles.d.ts +6 -3
  86. package/src/internal/SideMenuLogotype.styles.js +11 -10
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.10.0](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@0.9.5...@skbkontur/side-menu@0.10.0) (2023-05-26)
7
+
8
+
9
+ ### Features
10
+
11
+ * **SideMenu:** add customization ([a8d9f01](https://git.skbkontur.ru/ui/ui-parking/commits/a8d9f01967fe8faae5557ea272378f13fd520205))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [0.9.5](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@0.9.4...@skbkontur/side-menu@0.9.5) (2023-05-26)
7
18
 
8
19
  **Note:** Version bump only for package @skbkontur/side-menu
package/README.md CHANGED
@@ -590,16 +590,21 @@ const items = [
590
590
  ```
591
591
 
592
592
  ### Адаптивность
593
- Все брейкпойнты вынесены в пропы:
593
+ Брейкпойнты можно менять через пропы:
594
594
 
595
- | Проп | Дефолтное значение |
596
- | ------|--------------------|
597
- |desktopMediaQuery|'(min-width: 1200px)'|
598
- |narrowDesktopMediaQuery|'(min-width: 992px)'|
599
- |tabletMediaQuery|'(min-width: 768px)'|
600
- |mobileMediaQuery|'(min-width: 0px)'|
595
+ `desktopMediaQuery`
596
+ `narrowDesktopMediaQuery`
597
+ `tabletMediaQuery`
598
+ `mobileMediaQuery`
601
599
 
602
- Для того чтобы пропускать брекпойнты достаточно указать значение, равное следующему за ним брейкпойнту.
600
+ Либо через переменные темы:
601
+
602
+ `sideMenuDesktopMediaQuery = '(min-width: 1200px)';`
603
+ `sideMenuNarrowDesktopMediaQuery = '(min-width: 992px)';`
604
+ `sideMenuTabletMediaQuery = '(min-width: 768px)';`
605
+ `sideMenuMobileMediaQuery = '(min-width: 0px)';`
606
+
607
+ Для того чтобы пропускать брекпойнты, достаточно указать значение, равное следующему за ним брейкпойнту.
603
608
  Например, в следующем случае у `SideMenu` не будет адаптива для планшетов:
604
609
 
605
610
  `<SideMenu tabletMediaQuery={'(min-width: 768px)'} narrowDesktopMediaQuery={'(min-width: 768px)'}/>`
@@ -697,4 +702,80 @@ import { useHistory } from "react-router-dom";
697
702
  Детали реализации можно посмотреть здесь: https://github.com/remix-run/react-router/blob/v5/packages/react-router-dom/modules/Link.js#L36
698
703
 
699
704
 
700
- При необходимости вы можете повторить часть этой логики в своей обёртке.
705
+ При необходимости вы можете повторить часть этой логики в своей обёртке.
706
+
707
+ #### Пример кастомизации
708
+
709
+ ```jsx harmony
710
+ import { Kontur, Ofd } from '@skbkontur/logos';
711
+ import { SideMenu } from './index';
712
+ import {
713
+ DocTextIcon24Regular,
714
+ SettingsGearIcon24Regular,
715
+ } from '@skbkontur/icons';
716
+ import { ThemeContext, ThemeFactory } from "@skbkontur/react-ui";
717
+
718
+ <div style={{ height: '200px', position: 'relative' }}>
719
+ <ThemeContext.Provider value={ThemeFactory.create({ sideMenuWidth: '300px', sideMenuIconSize: '32px' })}>
720
+ <SideMenu disableSwipe={false}>
721
+ <SideMenu.Header konturLogo={<Kontur />} productLogo={<Ofd />} />
722
+ <SideMenu.Body>
723
+ <SideMenu.Item icon={<DocTextIcon24Regular />} caption={'Документы к подписанию'} marker={'новое'} />
724
+ </SideMenu.Body>
725
+ <SideMenu.Footer>
726
+ <SideMenu.Item icon={<SettingsGearIcon24Regular />} caption={'Реквизиты и настройки'} />
727
+ </SideMenu.Footer>
728
+ </SideMenu>
729
+ </ThemeContext.Provider>
730
+ </div>
731
+
732
+ ```
733
+
734
+ #### Переменные кастомизации (см. [ThemeContext](https://tech.skbkontur.ru/react-ui/#/Customization/ThemeContext))
735
+
736
+ ```typescript
737
+ {
738
+ sideMenuWidth: string;
739
+ sideMenuWidthForTouchScreens: string;
740
+ sideMenuMinimizedWidth: string;
741
+ sideMenuMarginX: string;
742
+ sideMenuBgColor: string;
743
+ sideMenuBoxShadowOffsetX: string;
744
+ sideMenuBoxShadowOffsetY: string;
745
+ sideMenuBoxShadowBlurRadius: string;
746
+ sideMenuBoxShadowColor: string;
747
+ sideMenuBoxShadow: string;
748
+ sideMenuLineHeight: string;
749
+ sideMenuLargeLineHeight: string;
750
+ sideMenuProductColor: string;
751
+ sideMenuFixedSeparatorColor: string;
752
+ sideMenuDesktopMediaQuery: string;
753
+ sideMenuNarrowDesktopMediaQuery: string;
754
+ sideMenuTabletMediaQuery: string;
755
+ sideMenuMobileMediaQuery: string;
756
+ //#region SeparatedSubMenu
757
+ sideMenuSeparatedSubMenuBgColor: string;
758
+ sideMenuSeparatedSubMenuBorderRightColor: string;
759
+ sideMenuSeparatedSubMenuPaddingY: string;
760
+ sideMenuSeparatedSubMenuPaddingX: string;
761
+ //#endregion
762
+ //#region NestedMenu
763
+ sideMenuNestedMenuPaddingLeft: string;
764
+ //#endregion
765
+ //#region RightBorder
766
+ MenuRightBorderWidth: string;
767
+ sideMenuRightBorderColor: string;
768
+ sideMenuRightBorderHoverWidth: string;
769
+ // #region BackButton (for Mobiles)
770
+ sideMenuBackButtonCaptionFontWeight: string;
771
+ sideMenuBackButtonCaptionFontSize: string;
772
+ sideMenuBackButtonCaptionLineHeight: string;
773
+ sideMenuBackButtonCaptionPaddingY: string;
774
+ sideMenuBackButtonIconPaddingLeft: string;
775
+ sideMenuBackButtonIconPaddingRight: string;
776
+ //#endregion
777
+ // #region Burger (for Mobiles or Tablets)
778
+ sideMenuBurgerMarginRight: string;
779
+ //#endregion
780
+ }
781
+ ```
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useState } from 'react';
2
- import { isElementActive } from '../utils/scripts';
2
+ import { isElementActive } from '../lib/utils/scripts';
3
3
  export var useActiveState = function (id, href, generatedId, activeMenuItem) {
4
4
  var _a = useState(false), isActive = _a[0], setIsActive = _a[1];
5
5
  useEffect(function () {
@@ -1,2 +1,13 @@
1
1
  import React from 'react';
2
- export declare const useNumberOfTextLinesInItem: (textRef: React.RefObject<HTMLDivElement>, setLinesNumber: React.Dispatch<React.SetStateAction<number>>, text?: string, marker?: string, size?: string) => void;
2
+ import { SideMenuTheme } from '../lib/theming/ThemeTypes';
3
+ interface UseNumberOfTextLinesInItem {
4
+ textRef: React.RefObject<HTMLDivElement>;
5
+ setLinesNumber: React.Dispatch<React.SetStateAction<number>>;
6
+ theme: SideMenuTheme;
7
+ caption?: string;
8
+ marker?: string;
9
+ size?: 'small' | 'large';
10
+ isTouchScreen?: boolean;
11
+ }
12
+ export declare const useNumberOfTextLinesInItem: ({ textRef, setLinesNumber, theme, caption, marker, size, isTouchScreen, }: UseNumberOfTextLinesInItem) => void;
13
+ export {};
@@ -1,31 +1,46 @@
1
- import { isBrowser } from '../utils/scripts';
2
- export var useNumberOfTextLinesInItem = function (textRef, setLinesNumber, text, marker, size) {
3
- if (text === void 0) { text = ''; }
4
- if (marker === void 0) { marker = ''; }
5
- if (size === void 0) { size = 'small'; }
6
- var getContainerWidth = function (ctx, marker) {
7
- var containerWidth = 232 - 2 * 16 - 24 - 2 * 8; //TODO после перехода на переменные темы заменить на формулу: side-menu-width - 2 * side-menu-paddingX - iconWidth - 2 * iconPaddingX
8
- var markerPaddings = marker ? 2 * 6 + 8 : 0; //TODO после перехода на переменные темы заменить на marker-padding-x и marker-margin-right
9
- var markerWidth = ctx.measureText(marker).width + markerPaddings;
10
- return containerWidth - markerWidth - 8; //TODO после перехода на переменные темы заменить на caption-margin-right
11
- };
12
- var getNumberOfLines = function (ctx, words, containerWidth) {
13
- var line = '';
14
- var lineCount = 1;
15
- words.forEach(function (word, i) {
16
- var testLine = (line + " " + word).trim();
17
- var testWidth = ctx.measureText(testLine).width;
18
- if (testWidth > containerWidth && i > 0) {
19
- line = '';
20
- lineCount++;
21
- }
22
- else {
23
- line = testLine;
24
- }
25
- });
26
- return lineCount;
27
- };
28
- var fontSize = size === 'small' ? 14 : 16; //TODO после перехода на переменные темы заменить на side-menu-font-size-small и side-menu-font-size-large
1
+ import { sideMenuCaptionMarginRight } from '../src/internal/ItemContent/Caption.styles';
2
+ import { isBrowser } from '../lib/utils/scripts';
3
+ var getNumberOfLines = function (ctx, words, containerWidth) {
4
+ var line = '';
5
+ var lineCount = 1;
6
+ words.forEach(function (word, i) {
7
+ var testLine = (line + " " + word).trim();
8
+ var testWidth = ctx.measureText(testLine).width;
9
+ if (testWidth > containerWidth && i > 0) {
10
+ line = '';
11
+ lineCount++;
12
+ }
13
+ else {
14
+ line = testLine;
15
+ }
16
+ });
17
+ return lineCount;
18
+ };
19
+ var getContainerWidth = function (ctx, marker, theme, isTouchScreen) {
20
+ var containerWidth = parseInt(isTouchScreen ? theme.sideMenuWidthForTouchScreens : theme.sideMenuWidth) -
21
+ 2 * parseInt(theme.sideMenuMarginX) -
22
+ parseInt(theme.sideMenuIconSize) -
23
+ 2 * parseInt(theme.sideMenuIconPaddingX);
24
+ var markerPaddings = marker
25
+ ? 2 * parseInt(theme.sideMenuMarkerPaddingX) + parseInt(theme.sideMenuMarkerMarginRight)
26
+ : 0;
27
+ var markerWidth = ctx.measureText(marker).width + markerPaddings;
28
+ return containerWidth - markerWidth - parseInt(sideMenuCaptionMarginRight);
29
+ };
30
+ var getFontSize = function (theme, isTouchScreen, size) {
31
+ if (size !== 'small') {
32
+ return parseInt(theme.sideMenuCaptionLargeFontSize);
33
+ }
34
+ if (isTouchScreen) {
35
+ return parseInt(theme.sideMenuCaptionFontSizeForTouchScreens);
36
+ }
37
+ else {
38
+ return parseInt(theme.sideMenuCaptionFontSize);
39
+ }
40
+ };
41
+ export var useNumberOfTextLinesInItem = function (_a) {
42
+ var textRef = _a.textRef, setLinesNumber = _a.setLinesNumber, theme = _a.theme, _b = _a.caption, caption = _b === void 0 ? '' : _b, _c = _a.marker, marker = _c === void 0 ? '' : _c, size = _a.size, isTouchScreen = _a.isTouchScreen;
43
+ var fontSize = getFontSize(theme, isTouchScreen, size);
29
44
  var fontFamily = textRef.current && isBrowser
30
45
  ? window.getComputedStyle(textRef.current).getPropertyValue('font-family')
31
46
  : "'Lab Grotesque', 'Segoe UI', 'Helvetica Neue', Roboto, Arial, sans-serif";
@@ -33,7 +48,7 @@ export var useNumberOfTextLinesInItem = function (textRef, setLinesNumber, text,
33
48
  var ctx = canvas.getContext('2d');
34
49
  if (ctx) {
35
50
  ctx.font = fontSize + "px " + fontFamily;
36
- var words = text.split(' ');
37
- setLinesNumber(getNumberOfLines(ctx, words, getContainerWidth(ctx, marker)));
51
+ var words = caption.split(' ');
52
+ setLinesNumber(getNumberOfLines(ctx, words, getContainerWidth(ctx, marker, theme, isTouchScreen)));
38
53
  }
39
54
  };
@@ -1,2 +1,3 @@
1
1
  import React from 'react';
2
- export declare const useNumberOfTextLinesInSubItem: (textRef: React.RefObject<HTMLDivElement>, setIsMultilineText: React.Dispatch<React.SetStateAction<boolean>>, size?: string) => void;
2
+ import { SideMenuTheme } from '../lib/theming/ThemeTypes';
3
+ export declare const useNumberOfTextLinesInSubItem: (textRef: React.RefObject<HTMLDivElement>, setIsMultilineText: React.Dispatch<React.SetStateAction<boolean>>, size: string | undefined, theme: SideMenuTheme) => void;
@@ -1,10 +1,10 @@
1
- export var useNumberOfTextLinesInSubItem = function (textRef, setIsMultilineText, size) {
1
+ export var useNumberOfTextLinesInSubItem = function (textRef, setIsMultilineText, size, theme) {
2
2
  if (size === void 0) { size = 'small'; }
3
3
  if (textRef.current) {
4
4
  var el_1 = textRef.current;
5
5
  setTimeout(function () {
6
6
  var textHeight = +el_1.offsetHeight;
7
- var lineHeight = size === 'small' ? 20 : 22; //TODO после возврата кастомизации заменить на переменные темы sideMenuLineHeight : sideMenuLargeLineHeight
7
+ var lineHeight = size === 'small' ? parseInt(theme.sideMenuLineHeight) : parseInt(theme.sideMenuLargeLineHeight);
8
8
  var lines = textHeight / lineHeight;
9
9
  if (lines >= 2) {
10
10
  setIsMultilineText(true);
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useState } from 'react';
2
- import { isParentOpened } from '../utils/scripts';
2
+ import { isParentOpened } from '../lib/utils/scripts';
3
3
  export var useOpenedState = function (id, generatedId, openedParents, isActive, children, separatedMenuIsShown, isMobileAndSeparatedMenu) {
4
4
  if (isActive === void 0) { isActive = false; }
5
5
  var _a = useState(false), isOpened = _a[0], setIsOpened = _a[1];
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useState } from 'react';
2
- import { isElementActive, isParentOpened } from '../utils/scripts';
2
+ import { isElementActive, isParentOpened } from '../lib/utils/scripts';
3
3
  export var useOpenedSubElementState = function (id, generatedId, openedParents, activeMenuItem) {
4
4
  var _a = useState(false), isOpened = _a[0], setIsOpened = _a[1];
5
5
  useEffect(function () {
@@ -0,0 +1,110 @@
1
+ import { Theme as ReactUITheme } from '@skbkontur/react-ui/lib/theming/Theme';
2
+ declare const SideMenuTheme_base: typeof import("@skbkontur/react-ui/internal/themes/DefaultTheme").DefaultTheme;
3
+ export declare class SideMenuTheme extends SideMenuTheme_base {
4
+ static sideMenuWidth: string;
5
+ static sideMenuWidthForTouchScreens: string;
6
+ static sideMenuMinimizedWidth: string;
7
+ static sideMenuMarginX: string;
8
+ static sideMenuBgColor: string;
9
+ static sideMenuBoxShadowOffsetX: string;
10
+ static sideMenuBoxShadowOffsetY: string;
11
+ static sideMenuBoxShadowBlurRadius: string;
12
+ static sideMenuBoxShadowColor: string;
13
+ static get sideMenuBoxShadow(): string;
14
+ static sideMenuLineHeight: string;
15
+ static sideMenuLargeLineHeight: string;
16
+ static sideMenuProductColor: string;
17
+ static sideMenuFixedSeparatorColor: string;
18
+ static sideMenuDesktopMediaQuery: string;
19
+ static sideMenuNarrowDesktopMediaQuery: string;
20
+ static sideMenuTabletMediaQuery: string;
21
+ static sideMenuMobileMediaQuery: string;
22
+ static sideMenuBodyPaddingBottom: string;
23
+ static sideMenuSeparatedSubMenuBgColor: string;
24
+ static sideMenuSeparatedSubMenuBorderRightColor: string;
25
+ static sideMenuSeparatedSubMenuPaddingY: string;
26
+ static sideMenuSeparatedSubMenuPaddingX: string;
27
+ static sideMenuSubItemHeaderFontSize: string;
28
+ static sideMenuSubItemHeaderColor: string;
29
+ static sideMenuSubItemHeaderPadding: string;
30
+ static sideMenuAvatarMargin: string;
31
+ static get sideMenuCaptionLineHeight(): string;
32
+ static sideMenuCaptionFontSize: string;
33
+ static sideMenuCaptionFontSizeForTouchScreens: string;
34
+ static sideMenuCaptionLineHeightForTouchScreens: string;
35
+ static sideMenuCaptionSubItemMarginLeft: string;
36
+ static sideMenuCaptionSubItemFontSizeForTouchScreens: string;
37
+ static get sideMenuCaptionSubItemLineHeightForTouchScreens(): string;
38
+ static sideMenuCaptionLargeFontSize: string;
39
+ static get sideMenuCaptionLargeLineHeight(): string;
40
+ static sideMenuBackButtonCaptionFontWeight: string;
41
+ static sideMenuBackButtonCaptionFontSize: string;
42
+ static sideMenuBackButtonCaptionLineHeight: string;
43
+ static sideMenuBackButtonCaptionPaddingY: string;
44
+ static sideMenuBackButtonIconPaddingLeft: string;
45
+ static sideMenuBackButtonIconPaddingRight: string;
46
+ static sideMenuIconSize: string;
47
+ static sideMenuIconSubItemSize: string;
48
+ static sideMenuIconPaddingY: string;
49
+ static sideMenuIconPaddingX: string;
50
+ static sideMenuIconMinHeight: string;
51
+ static get sideMenuIconLineHeight(): string;
52
+ static sideMenuIconLargeMinHeight: string;
53
+ static get sideMenuIconLargeLineHeight(): string;
54
+ static sideMenuIconSubItemPaddingLeft: string;
55
+ static sideMenuIconSubItemPaddingRight: string;
56
+ static sideMenuIconSubItemMinHeight: string;
57
+ static sideMenuIconSubItemLineHeight: string;
58
+ static sideMenuIconSubItemColor: string;
59
+ static sideMenuIconLargeSubItemMinHeight: string;
60
+ static sideMenuIconWithSeparatedSubMenuSubItemPaddingLeft: string;
61
+ static sideMenuItemContentPaddingY: string;
62
+ static sideMenuItemContentLargePaddingY: string;
63
+ static sideMenuSubItemContentPaddingY: string;
64
+ static sideMenuSubItemContentLargePaddingY: string;
65
+ static sideMenuItemContentLargeMultilinePaddingY: string;
66
+ static sideMenuItemContentPaddingYForTouchScreens: string;
67
+ static sideMenuSubItemContentPaddingYForTouchScreens: string;
68
+ static sideMenuMarkerPaddingX: string;
69
+ static get sideMenuMarkerBg(): string;
70
+ static sideMenuMarkerColor: string;
71
+ static sideMenuMarkerMarginRight: string;
72
+ static sideMenuMarkerFontWeight: string;
73
+ static sideMenuMarkerMultilineMarginTop: string;
74
+ static sideMenuBurgerMarginRight: string;
75
+ static sideMenuItemBorderRadius: string;
76
+ static sideMenuItemHoverBg: string;
77
+ static sideMenuItemActiveBg: string;
78
+ static sideMenuSubItemWithSeparatedSubMenuHoverBg: string;
79
+ static sideMenuSubItemWithSeparatedSubMenuActiveBg: string;
80
+ static sideMenuFocusedItemBoxShadowInset: string;
81
+ static sideMenuFocusedItemBoxShadowOffsetX: string;
82
+ static sideMenuFocusedItemBoxShadowOffsetY: string;
83
+ static sideMenuFocusedItemBoxShadowBlurRadius: string;
84
+ static sideMenuFocusedItemBoxShadowSpreadRadius: string;
85
+ static sideMenuFocusedItemBoxShadowColor: string;
86
+ static get sideMenuFocusedItemBoxShadow(): string;
87
+ static sideMenuDividerBgColor: string;
88
+ static sideMenuDividerMarginX: string;
89
+ static sideMenuNestedMenuPaddingLeft: string;
90
+ static sideMenuRightBorderWidth: string;
91
+ static get sideMenuRightBorderColor(): string;
92
+ static sideMenuRightBorderHoverWidth: string;
93
+ static sideMenuLogotypePaddingLeft: string;
94
+ static sideMenuLogotypePaddingTop: string;
95
+ static sideMenuLogotypePaddingBottom: string;
96
+ static sideMenuLogotypePaddingYForTouchScreens: string;
97
+ static sideMenuLogotypeHiddenIconPaddingLeft: string;
98
+ static sideMenuFooterPaddingBottom: string;
99
+ static sideMenuFooterPaddingTop: string;
100
+ static get sideMenuFooterDividerColor(): string;
101
+ static sideMenuHeaderPaddingTop: string;
102
+ static sideMenuHeaderPaddingBottom: string;
103
+ static get sideMenuHeaderDividerColor(): string;
104
+ static sideMenuHeaderPaddingTopForTouchScreens: string;
105
+ }
106
+ export declare const REACT_UI_SIDE_MENU_THEME_KEY = "__IS_REACT_UI_SIDE_MENU_THEME__";
107
+ export declare const markAsSideMenuTheme: <T extends object>(theme: T) => T;
108
+ export declare const isSideMenuTheme: (theme: ReactUITheme | SideMenuTheme) => boolean;
109
+ export declare const SideMenuThemeInternal: typeof SideMenuTheme;
110
+ export {};
@@ -0,0 +1,234 @@
1
+ import { __extends } from "tslib";
2
+ import { exposeGetters } from '@skbkontur/react-ui/lib/theming/ThemeHelpers';
3
+ var SideMenuTheme = /** @class */ (function (_super) {
4
+ __extends(SideMenuTheme, _super);
5
+ function SideMenuTheme() {
6
+ return _super !== null && _super.apply(this, arguments) || this;
7
+ }
8
+ Object.defineProperty(SideMenuTheme, "sideMenuBoxShadow", {
9
+ get: function () {
10
+ return this.sideMenuBoxShadowOffsetX + " " + this.sideMenuBoxShadowOffsetY + " " + this.sideMenuBoxShadowBlurRadius + " " + this.sideMenuBoxShadowColor;
11
+ },
12
+ enumerable: false,
13
+ configurable: true
14
+ });
15
+ Object.defineProperty(SideMenuTheme, "sideMenuCaptionLineHeight", {
16
+ //#endregion
17
+ // #region Caption
18
+ get: function () {
19
+ return this.sideMenuLineHeight;
20
+ },
21
+ enumerable: false,
22
+ configurable: true
23
+ });
24
+ Object.defineProperty(SideMenuTheme, "sideMenuCaptionSubItemLineHeightForTouchScreens", {
25
+ get: function () {
26
+ return this.sideMenuLargeLineHeight;
27
+ },
28
+ enumerable: false,
29
+ configurable: true
30
+ });
31
+ Object.defineProperty(SideMenuTheme, "sideMenuCaptionLargeLineHeight", {
32
+ get: function () {
33
+ return this.sideMenuLargeLineHeight;
34
+ },
35
+ enumerable: false,
36
+ configurable: true
37
+ });
38
+ Object.defineProperty(SideMenuTheme, "sideMenuIconLineHeight", {
39
+ get: function () {
40
+ return this.sideMenuLineHeight;
41
+ },
42
+ enumerable: false,
43
+ configurable: true
44
+ });
45
+ Object.defineProperty(SideMenuTheme, "sideMenuIconLargeLineHeight", {
46
+ get: function () {
47
+ return this.sideMenuLargeLineHeight;
48
+ },
49
+ enumerable: false,
50
+ configurable: true
51
+ });
52
+ Object.defineProperty(SideMenuTheme, "sideMenuMarkerBg", {
53
+ get: function () {
54
+ return this.sideMenuProductColor;
55
+ },
56
+ enumerable: false,
57
+ configurable: true
58
+ });
59
+ Object.defineProperty(SideMenuTheme, "sideMenuFocusedItemBoxShadow", {
60
+ get: function () {
61
+ return this.sideMenuFocusedItemBoxShadowInset + " " + this.sideMenuFocusedItemBoxShadowOffsetX + " " + this.sideMenuFocusedItemBoxShadowOffsetY + " " + this.sideMenuFocusedItemBoxShadowBlurRadius + " " + this.sideMenuFocusedItemBoxShadowSpreadRadius + " " + this.sideMenuFocusedItemBoxShadowColor;
62
+ },
63
+ enumerable: false,
64
+ configurable: true
65
+ });
66
+ Object.defineProperty(SideMenuTheme, "sideMenuRightBorderColor", {
67
+ get: function () {
68
+ return this.sideMenuProductColor;
69
+ },
70
+ enumerable: false,
71
+ configurable: true
72
+ });
73
+ Object.defineProperty(SideMenuTheme, "sideMenuFooterDividerColor", {
74
+ get: function () {
75
+ return this.sideMenuFixedSeparatorColor;
76
+ },
77
+ enumerable: false,
78
+ configurable: true
79
+ });
80
+ Object.defineProperty(SideMenuTheme, "sideMenuHeaderDividerColor", {
81
+ get: function () {
82
+ return this.sideMenuFixedSeparatorColor;
83
+ },
84
+ enumerable: false,
85
+ configurable: true
86
+ });
87
+ //#region SideMenu
88
+ SideMenuTheme.sideMenuWidth = '232px';
89
+ SideMenuTheme.sideMenuWidthForTouchScreens = '328px';
90
+ SideMenuTheme.sideMenuMinimizedWidth = '72px';
91
+ SideMenuTheme.sideMenuMarginX = '16px';
92
+ SideMenuTheme.sideMenuBgColor = '#f6f6f6';
93
+ SideMenuTheme.sideMenuBoxShadowOffsetX = '4px';
94
+ SideMenuTheme.sideMenuBoxShadowOffsetY = '4px';
95
+ SideMenuTheme.sideMenuBoxShadowBlurRadius = '24px';
96
+ SideMenuTheme.sideMenuBoxShadowColor = 'rgba(0, 0, 0, 0.24)';
97
+ SideMenuTheme.sideMenuLineHeight = '20px';
98
+ SideMenuTheme.sideMenuLargeLineHeight = '22px';
99
+ SideMenuTheme.sideMenuProductColor = '#2291ff';
100
+ SideMenuTheme.sideMenuFixedSeparatorColor = '#e6e6e6';
101
+ SideMenuTheme.sideMenuDesktopMediaQuery = '(min-width: 1200px)';
102
+ SideMenuTheme.sideMenuNarrowDesktopMediaQuery = '(min-width: 992px)';
103
+ SideMenuTheme.sideMenuTabletMediaQuery = '(min-width: 768px)';
104
+ SideMenuTheme.sideMenuMobileMediaQuery = '(min-width: 0px)';
105
+ //#endregion
106
+ //#region Body
107
+ SideMenuTheme.sideMenuBodyPaddingBottom = '8px';
108
+ //#endregion
109
+ //#region SeparatedSubMenu
110
+ SideMenuTheme.sideMenuSeparatedSubMenuBgColor = '#fff';
111
+ SideMenuTheme.sideMenuSeparatedSubMenuBorderRightColor = '#e5e5e5';
112
+ SideMenuTheme.sideMenuSeparatedSubMenuPaddingY = '24px';
113
+ SideMenuTheme.sideMenuSeparatedSubMenuPaddingX = '16px';
114
+ //#endregion
115
+ //#region SubItemHeader
116
+ SideMenuTheme.sideMenuSubItemHeaderFontSize = '12px';
117
+ SideMenuTheme.sideMenuSubItemHeaderColor = 'rgba(0, 0, 0, 0.48)';
118
+ SideMenuTheme.sideMenuSubItemHeaderPadding = '10px 8px 2px 40px';
119
+ //#endregion
120
+ //#region Avatar
121
+ SideMenuTheme.sideMenuAvatarMargin = '0 4px';
122
+ SideMenuTheme.sideMenuCaptionFontSize = '14px';
123
+ SideMenuTheme.sideMenuCaptionFontSizeForTouchScreens = '18px';
124
+ SideMenuTheme.sideMenuCaptionLineHeightForTouchScreens = '24px';
125
+ SideMenuTheme.sideMenuCaptionSubItemMarginLeft = '4px';
126
+ SideMenuTheme.sideMenuCaptionSubItemFontSizeForTouchScreens = '16px';
127
+ SideMenuTheme.sideMenuCaptionLargeFontSize = '16px';
128
+ //#endregion
129
+ // #region BackButton
130
+ SideMenuTheme.sideMenuBackButtonCaptionFontWeight = '700';
131
+ SideMenuTheme.sideMenuBackButtonCaptionFontSize = '20px';
132
+ SideMenuTheme.sideMenuBackButtonCaptionLineHeight = '28px';
133
+ SideMenuTheme.sideMenuBackButtonCaptionPaddingY = '5px';
134
+ SideMenuTheme.sideMenuBackButtonIconPaddingLeft = '10px';
135
+ SideMenuTheme.sideMenuBackButtonIconPaddingRight = '6px';
136
+ //#endregion
137
+ // #region Icon
138
+ SideMenuTheme.sideMenuIconSize = '24';
139
+ SideMenuTheme.sideMenuIconSubItemSize = '16';
140
+ SideMenuTheme.sideMenuIconPaddingY = '0';
141
+ SideMenuTheme.sideMenuIconPaddingX = '8px';
142
+ SideMenuTheme.sideMenuIconMinHeight = '32px';
143
+ SideMenuTheme.sideMenuIconLargeMinHeight = '30px';
144
+ SideMenuTheme.sideMenuIconSubItemPaddingLeft = '20px';
145
+ SideMenuTheme.sideMenuIconSubItemPaddingRight = '0';
146
+ SideMenuTheme.sideMenuIconSubItemMinHeight = '20px';
147
+ SideMenuTheme.sideMenuIconSubItemLineHeight = '16px';
148
+ SideMenuTheme.sideMenuIconSubItemColor = '#858585';
149
+ SideMenuTheme.sideMenuIconLargeSubItemMinHeight = '22px';
150
+ SideMenuTheme.sideMenuIconWithSeparatedSubMenuSubItemPaddingLeft = '4px';
151
+ //#endregion
152
+ // #region ItemContent
153
+ SideMenuTheme.sideMenuItemContentPaddingY = '4px';
154
+ SideMenuTheme.sideMenuItemContentLargePaddingY = '9px';
155
+ SideMenuTheme.sideMenuSubItemContentPaddingY = '4px';
156
+ SideMenuTheme.sideMenuSubItemContentLargePaddingY = '5px';
157
+ SideMenuTheme.sideMenuItemContentLargeMultilinePaddingY = '5px';
158
+ SideMenuTheme.sideMenuItemContentPaddingYForTouchScreens = '8px';
159
+ SideMenuTheme.sideMenuSubItemContentPaddingYForTouchScreens = '9px';
160
+ //#endregion
161
+ // #region Marker
162
+ SideMenuTheme.sideMenuMarkerPaddingX = '6px';
163
+ SideMenuTheme.sideMenuMarkerColor = '#fff';
164
+ SideMenuTheme.sideMenuMarkerMarginRight = '8px';
165
+ SideMenuTheme.sideMenuMarkerFontWeight = '700';
166
+ SideMenuTheme.sideMenuMarkerMultilineMarginTop = '4px';
167
+ //#endregion
168
+ // #region Burger
169
+ SideMenuTheme.sideMenuBurgerMarginRight = '8px';
170
+ //#endregion
171
+ // #region MenuItem
172
+ SideMenuTheme.sideMenuItemBorderRadius = '8px';
173
+ SideMenuTheme.sideMenuItemHoverBg = 'rgba(255, 255, 255, 0.48)';
174
+ SideMenuTheme.sideMenuItemActiveBg = '#fff';
175
+ SideMenuTheme.sideMenuSubItemWithSeparatedSubMenuHoverBg = '#f6f6f6';
176
+ SideMenuTheme.sideMenuSubItemWithSeparatedSubMenuActiveBg = '#f2f2f2';
177
+ SideMenuTheme.sideMenuFocusedItemBoxShadowInset = 'inset';
178
+ SideMenuTheme.sideMenuFocusedItemBoxShadowOffsetX = '0';
179
+ SideMenuTheme.sideMenuFocusedItemBoxShadowOffsetY = '0';
180
+ SideMenuTheme.sideMenuFocusedItemBoxShadowBlurRadius = '0';
181
+ SideMenuTheme.sideMenuFocusedItemBoxShadowSpreadRadius = '2px';
182
+ SideMenuTheme.sideMenuFocusedItemBoxShadowColor = '#1c7edf';
183
+ //#endregion
184
+ //#region Divider
185
+ SideMenuTheme.sideMenuDividerBgColor = '#d6d6d6';
186
+ SideMenuTheme.sideMenuDividerMarginX = '8px';
187
+ //#endregion
188
+ //#region NestedMenu
189
+ SideMenuTheme.sideMenuNestedMenuPaddingLeft = '16px';
190
+ //#endregion
191
+ //#region RightBorder
192
+ SideMenuTheme.sideMenuRightBorderWidth = '20px';
193
+ SideMenuTheme.sideMenuRightBorderHoverWidth = '2px';
194
+ //#endregion
195
+ //#region Logotype
196
+ SideMenuTheme.sideMenuLogotypePaddingLeft = '8px';
197
+ SideMenuTheme.sideMenuLogotypePaddingTop = '2px';
198
+ SideMenuTheme.sideMenuLogotypePaddingBottom = '6px';
199
+ SideMenuTheme.sideMenuLogotypePaddingYForTouchScreens = '8px';
200
+ SideMenuTheme.sideMenuLogotypeHiddenIconPaddingLeft = '4px';
201
+ //#endregion
202
+ //#region Footer
203
+ SideMenuTheme.sideMenuFooterPaddingBottom = '24px';
204
+ SideMenuTheme.sideMenuFooterPaddingTop = '8px';
205
+ //#endregion
206
+ //#region Header
207
+ SideMenuTheme.sideMenuHeaderPaddingTop = '24px';
208
+ SideMenuTheme.sideMenuHeaderPaddingBottom = '8px';
209
+ SideMenuTheme.sideMenuHeaderPaddingTopForTouchScreens = '16px';
210
+ return SideMenuTheme;
211
+ }(/** @class */ (function () {
212
+ function class_1() {
213
+ }
214
+ return class_1;
215
+ }())));
216
+ export { SideMenuTheme };
217
+ export var REACT_UI_SIDE_MENU_THEME_KEY = '__IS_REACT_UI_SIDE_MENU_THEME__';
218
+ export var markAsSideMenuTheme = function (theme) {
219
+ var _a;
220
+ return Object.create(theme, (_a = {},
221
+ _a[REACT_UI_SIDE_MENU_THEME_KEY] = {
222
+ value: true,
223
+ writable: false,
224
+ enumerable: false,
225
+ configurable: false,
226
+ },
227
+ _a));
228
+ };
229
+ export var isSideMenuTheme = function (theme) {
230
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
231
+ //@ts-ignore
232
+ return theme[REACT_UI_SIDE_MENU_THEME_KEY] === true;
233
+ };
234
+ export var SideMenuThemeInternal = exposeGetters(SideMenuTheme);
@@ -0,0 +1,18 @@
1
+ import { Theme as ReactUITheme } from '@skbkontur/react-ui/lib/theming/Theme';
2
+ import { SideMenuTheme } from './ThemeTypes';
3
+ /**
4
+ * Creates SideMenuTheme out of ReactUI's Theme.
5
+ *
6
+ * Inserts SideMenu vars in the theme, puts them over ReactUI's vars,
7
+ * but respects these SideMenu vars values that might have been specified in ReactUI's theme before that.
8
+ *
9
+ * This allows inserting SideMenu vars in the theme on the fly
10
+ * (without need for users to do it manually in their apps),
11
+ * and using ReactUI's ThemeContext.Provider for overriding them.
12
+ */
13
+ export declare const createSideMenuTheme: (theme: ReactUITheme | SideMenuTheme) => SideMenuTheme;
14
+ export declare const getSideMenuTheme: (() => Readonly<typeof import("../../internal/themes/SideMenuTheme").SideMenuTheme>) | ((arg: Readonly<typeof import("@skbkontur/react-ui/internal/themes/DefaultTheme").DefaultTheme> | Readonly<typeof import("../../internal/themes/SideMenuTheme").SideMenuTheme>) => Readonly<typeof import("../../internal/themes/SideMenuTheme").SideMenuTheme>);
15
+ export declare const memoizeStyle: <S extends {
16
+ [className: string]: (() => string) | ((t: SideMenuTheme) => string);
17
+ }>(styles: S) => S;
18
+ export declare const cssName: (className: string) => string;