@skbkontur/side-menu 0.14.4 → 0.14.6

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 CHANGED
@@ -3,6 +3,22 @@
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.14.6](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@0.14.5...@skbkontur/side-menu@0.14.6) (2023-07-20)
7
+
8
+ **Note:** Version bump only for package @skbkontur/side-menu
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.14.5](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@0.14.4...@skbkontur/side-menu@0.14.5) (2023-07-13)
15
+
16
+ **Note:** Version bump only for package @skbkontur/side-menu
17
+
18
+
19
+
20
+
21
+
6
22
  ## [0.14.4](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@0.14.3...@skbkontur/side-menu@0.14.4) (2023-07-04)
7
23
 
8
24
  **Note:** Version bump only for package @skbkontur/side-menu
@@ -1,4 +1,4 @@
1
- import { ReactElement } from 'react';
1
+ import React, { ReactElement } from 'react';
2
2
  import { FlattedArrayElementType } from '../../src/internal/InnerBody';
3
3
  export declare const getItemId: (prefix: 'body' | 'footer', id: string | number) => string;
4
4
  export declare const isClickableSubElement: (element: string) => boolean;
@@ -10,3 +10,4 @@ export declare const isParentOpened: (id: string | undefined, generatedId: strin
10
10
  export declare const isElementActive: (id: string | undefined, activeMenuItem: string | undefined | null) => boolean;
11
11
  export declare const isBrowser: boolean;
12
12
  export declare const isTouchDevice: () => boolean;
13
+ export declare const isKonturIcon: (icon: React.ReactElement) => boolean;
@@ -77,3 +77,6 @@ export var isBrowser = typeof window !== 'undefined';
77
77
  export var isTouchDevice = function () {
78
78
  return isBrowser && ('ontouchstart' in window || navigator.maxTouchPoints > 0);
79
79
  };
80
+ export var isKonturIcon = function (icon) {
81
+ return Object.prototype.hasOwnProperty.call(icon === null || icon === void 0 ? void 0 : icon.type, '__KONTUR_ICON__');
82
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skbkontur/side-menu",
3
- "version": "0.14.4",
3
+ "version": "0.14.6",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"
@@ -1,7 +1,6 @@
1
- import React from 'react';
2
1
  import { SideMenuItemProps } from '../../SideMenuItem/SideMenuItem';
3
2
  interface IconProps extends Pick<SideMenuItemProps, '_isSubMenu' | 'icon' | '_isBackButton' | '_isAvatar'> {
4
3
  isMultiline: boolean;
5
4
  }
6
- export declare const Icon: ({ icon, _isSubMenu, isMultiline, _isBackButton, _isAvatar }: IconProps) => React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>;
5
+ export declare const Icon: ({ icon, _isSubMenu, isMultiline, _isBackButton, _isAvatar }: IconProps) => JSX.Element;
7
6
  export {};
@@ -4,6 +4,7 @@ import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
4
4
  import { jsStyles } from './Icon.styles';
5
5
  import { SideMenuContext } from '../../SideMenuContext';
6
6
  import { getSideMenuTheme } from '../../../lib/theming/ThemeHelpers';
7
+ import { isKonturIcon } from '../../../lib/utils/scripts';
7
8
  var getIconSize = function (theme, _isSubMenu, _isBackButton) {
8
9
  if (!_isSubMenu) {
9
10
  return parseInt(theme.sideMenuIconSize);
@@ -18,11 +19,17 @@ export var Icon = function (_a) {
18
19
  var context = useContext(SideMenuContext);
19
20
  var isSeparatedMenu = context.isSeparatedMenu, size = context.size;
20
21
  var theme = getSideMenuTheme(useContext(ThemeContext));
21
- return React.cloneElement(icon, {
22
- size: getIconSize(theme, _isSubMenu, _isBackButton),
23
- color: _isSubMenu ? theme.sideMenuIconSubItemColor : undefined,
24
- align: _isBackButton ? 'baseline' : 'none',
25
- className: cx((_b = {},
22
+ var renderIcon = function () {
23
+ if (isKonturIcon(icon)) {
24
+ return React.cloneElement(icon, {
25
+ size: getIconSize(theme, _isSubMenu, _isBackButton),
26
+ color: _isSubMenu ? theme.sideMenuIconSubItemColor : undefined,
27
+ align: _isBackButton ? 'baseline' : 'none',
28
+ });
29
+ }
30
+ return icon;
31
+ };
32
+ return (React.createElement("span", { className: cx((_b = {},
26
33
  _b[jsStyles.root(theme)] = true,
27
34
  _b[jsStyles.rootMultiline()] = isMultiline && (!context.isMinimized || _isSubMenu),
28
35
  _b[jsStyles.rootLarge(theme)] = size === 'large',
@@ -31,6 +38,5 @@ export var Icon = function (_a) {
31
38
  _b[jsStyles.rootSubItemLarge(theme)] = _isSubMenu && size === 'large',
32
39
  _b[jsStyles.rootBackButton(theme)] = _isBackButton,
33
40
  _b[jsStyles.rootAvatar()] = _isAvatar,
34
- _b)),
35
- });
41
+ _b)) }, renderIcon()));
36
42
  };
@@ -6,7 +6,7 @@ var styles = {
6
6
  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.sideMenuIconMarginX, t.sideMenuIconMinHeight, t.sideMenuIconLineHeight);
7
7
  },
8
8
  rootMultiline: function () {
9
- return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n align-self: flex-start;\n align-items: flex-start;\n "], ["\n align-self: flex-start;\n align-items: flex-start;\n "])));
9
+ return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n align-self: flex-start;\n "], ["\n align-self: flex-start;\n "])));
10
10
  },
11
11
  rootLarge: function (t) {
12
12
  return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n min-height: ", ";\n line-height: ", ";\n "], ["\n min-height: ", ";\n line-height: ", ";\n "])), t.sideMenuIconLargeMinHeight, t.sideMenuIconLargeLineHeight);
@@ -48,13 +48,16 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
48
48
  var getStaticIconPath = function () {
49
49
  return "https://s.kontur.ru/common-v2/icons-products/" + productName + "/" + productName + "-" + parseInt(sideMenuLogotypeIconSize) + ".svg";
50
50
  };
51
- var getWidget = function (withWidget, isTouchScreen, showWidget) {
51
+ var getWidget = function (withWidget, isTouchScreen, isMinimizedInNarrowDesktop, showWidget) {
52
52
  if (withWidget !== undefined) {
53
53
  return withWidget;
54
54
  }
55
55
  if (isTouchScreen) {
56
56
  return true;
57
57
  }
58
+ else if (isMinimizedInNarrowDesktop) {
59
+ return false;
60
+ }
58
61
  return showWidget;
59
62
  };
60
63
  return (React.createElement("div", { className: jsStyles.root(), ref: ref },
@@ -68,7 +71,7 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
68
71
  _c[jsStyles.logoWrapperHidden()] = context.isMinimized,
69
72
  _c)) },
70
73
  (context.isTablet || context.isMobile) && React.createElement(Burger, null),
71
- React.createElement(Logotype, __assign({ ref: refLogotype, size: size, productLogo: productLogo, konturLogo: konturLogo, withWidget: getWidget(withWidget, context.isTouchScreen, context.showWidget) }, rest)))));
74
+ React.createElement(Logotype, __assign({ ref: refLogotype, size: size, productLogo: productLogo, konturLogo: konturLogo, withWidget: getWidget(withWidget, context.isTouchScreen, context.isMinimized && context.isNarrowDesktop, context.showWidget) }, rest)))));
72
75
  });
73
76
  SideMenuLogotype.displayName = 'SideMenuLogotype';
74
77
  var SideMenuLogotypeWithStaticFields = Object.assign(SideMenuLogotype, { __KONTUR_REACT_UI__: 'SideMenuLogotype' });