@skbkontur/side-menu 1.2.0 → 1.3.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 CHANGED
@@ -3,6 +3,25 @@
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
+ # [1.3.0](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@1.2.1...@skbkontur/side-menu@1.3.0) (2023-08-22)
7
+
8
+
9
+ ### Features
10
+
11
+ * **SideMenu:** fix animation logic ([0d80df9](https://git.skbkontur.ru/ui/ui-parking/commits/0d80df987faae0970f67680239b8a933fa32bcc7))
12
+
13
+
14
+
15
+
16
+
17
+ ## [1.2.1](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@1.2.0...@skbkontur/side-menu@1.2.1) (2023-08-21)
18
+
19
+ **Note:** Version bump only for package @skbkontur/side-menu
20
+
21
+
22
+
23
+
24
+
6
25
  # [1.2.0](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@1.1.0...@skbkontur/side-menu@1.2.0) (2023-08-18)
7
26
 
8
27
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skbkontur/side-menu",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@skbkontur/icons": "^1.4.3",
26
- "@skbkontur/react-ui-addons": "^4.9.0",
26
+ "@skbkontur/react-ui-addons": "^4.9.1",
27
27
  "tslib": "^1"
28
28
  }
29
29
  }
@@ -207,12 +207,14 @@ var SideMenuInner = forwardRef(function (_a, ref) {
207
207
  _d[jsStylesForSideMenu.container(theme)] = true,
208
208
  _d[jsStylesForSideMenu.collapsedContainerForTabletsOrMobiles()] = !isShown && !isBeingTransitioned,
209
209
  _d[jsStylesForSideMenu.minimizedContainer(theme)] = isMinimized,
210
- _d[jsStylesForSideMenu.innerContainer()] = !isSeparatedMenu,
210
+ _d[jsStylesForSideMenu.innerContainer()] = !isSeparatedMenuShown,
211
211
  _d[jsStylesForSideMenu.containerForTouchScreens(theme)] = isTouchScreen,
212
212
  _d[jsStylesForSideMenu.separatedContainerForMobiles(theme)] = isMobile && isSeparatedMenuShown && (isShown || isBeingTransitioned),
213
213
  _d)) },
214
214
  React.createElement("div", { className: cx((_e = {},
215
- _e[jsStylesForSideMenu.contentWrapper()] = true,
215
+ _e[jsStylesForSideMenu.contentWrapper(theme)] = true,
216
+ _e[jsStylesForSideMenu.contentWrapperForTouchScreens(theme)] = isTouchScreen,
217
+ _e[jsStylesForSideMenu.minimizedContentWrapper()] = isMinimized,
216
218
  _e)) }, children)),
217
219
  !disableSwipe && isDesktopQuery && !isSeparatedMenuShown && (React.createElement(RightBorder, { setIsMinimized: setIsMinimized }))))))));
218
220
  });
@@ -13,7 +13,9 @@ export declare const jsStylesForSideMenu: {
13
13
  innerContainer(): string;
14
14
  containerForTouchScreens(t: SideMenuTheme): string;
15
15
  separatedContainerForMobiles(t: SideMenuTheme): string;
16
- contentWrapper(): string;
16
+ contentWrapper(t: SideMenuTheme): string;
17
+ contentWrapperForTouchScreens(t: SideMenuTheme): string;
18
+ minimizedContentWrapper(): string;
17
19
  wrapper(): string;
18
20
  wrapperIE(): string;
19
21
  wrapperWithShadow(t: SideMenuTheme): string;
@@ -33,30 +33,36 @@ var styles = {
33
33
  separatedContainerForMobiles: function (t) {
34
34
  return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n background: ", ";\n "], ["\n background: ", ";\n "])), t.sideMenuSeparatedSubMenuBgColor);
35
35
  },
36
- contentWrapper: function () {
37
- return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n height: 100%;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n overflow: hidden;\n "], ["\n height: 100%;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n overflow: hidden;\n "])));
36
+ contentWrapper: function (t) {
37
+ return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n height: 100%;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n overflow: hidden;\n width: ", ";\n "], ["\n height: 100%;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n overflow: hidden;\n width: ", ";\n "])), t.sideMenuWidth);
38
+ },
39
+ contentWrapperForTouchScreens: function (t) {
40
+ return css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n width: ", ";\n "], ["\n width: ", ";\n "])), t.sideMenuWidthForTouchScreens);
41
+ },
42
+ minimizedContentWrapper: function () {
43
+ return css(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n width: 100%;\n "], ["\n width: 100%;\n "])));
38
44
  },
39
45
  wrapper: function () {
40
- return css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n height: 100%;\n display: inline-flex;\n position: relative;\n "], ["\n height: 100%;\n display: inline-flex;\n position: relative;\n "])));
46
+ return css(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n height: 100%;\n display: inline-flex;\n position: relative;\n "], ["\n height: 100%;\n display: inline-flex;\n position: relative;\n "])));
41
47
  },
42
48
  wrapperIE: function () {
43
49
  var ieRootWrapperCorrection = 15;
44
- return css(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n position: relative;\n top: -", ";\n height: calc(100% + ", ");\n "], ["\n position: relative;\n top: -", ";\n height: calc(100% + ", ");\n "])), ieRootWrapperCorrection, ieRootWrapperCorrection);
50
+ return css(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n position: relative;\n top: -", ";\n height: calc(100% + ", ");\n "], ["\n position: relative;\n top: -", ";\n height: calc(100% + ", ");\n "])), ieRootWrapperCorrection, ieRootWrapperCorrection);
45
51
  },
46
52
  wrapperWithShadow: function (t) {
47
- return css(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n box-shadow: ", ";\n "], ["\n box-shadow: ", ";\n "])), t.sideMenuBoxShadow);
53
+ return css(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n box-shadow: ", ";\n "], ["\n box-shadow: ", ";\n "])), t.sideMenuBoxShadow);
48
54
  },
49
55
  collapsedContainerForTabletsOrMobiles: function () {
50
- return css(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n background-color: transparent;\n "], ["\n background-color: transparent;\n "])));
56
+ return css(templateObject_17 || (templateObject_17 = __makeTemplateObject(["\n background-color: transparent;\n "], ["\n background-color: transparent;\n "])));
51
57
  },
52
58
  list: function () {
53
- return css(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n list-style: none;\n padding: 0;\n margin: 0;\n "], ["\n list-style: none;\n padding: 0;\n margin: 0;\n "])));
59
+ return css(templateObject_18 || (templateObject_18 = __makeTemplateObject(["\n list-style: none;\n padding: 0;\n margin: 0;\n "], ["\n list-style: none;\n padding: 0;\n margin: 0;\n "])));
54
60
  },
55
61
  };
56
62
  export var customStyles = {
57
63
  rootForTabletsOrMobiles: function (headerHeight) {
58
- return css(templateObject_17 || (templateObject_17 = __makeTemplateObject(["\n height: ", "px;\n position: absolute;\n top: 0;\n transition: height ", "ms ease-out;\n "], ["\n height: ", "px;\n position: absolute;\n top: 0;\n transition: height ", "ms ease-out;\n "])), headerHeight, burgerTransitionDuration);
64
+ return css(templateObject_19 || (templateObject_19 = __makeTemplateObject(["\n height: ", "px;\n position: absolute;\n top: 0;\n transition: height ", "ms ease-out;\n "], ["\n height: ", "px;\n position: absolute;\n top: 0;\n transition: height ", "ms ease-out;\n "])), headerHeight, burgerTransitionDuration);
59
65
  },
60
66
  };
61
67
  export var jsStylesForSideMenu = memoizeStyle(styles);
62
- 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;
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;
@@ -10,7 +10,7 @@ import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers';
10
10
  import { getDOMRect } from '@skbkontur/react-ui/lib/dom/getDOMRect';
11
11
  var SideMenuHeaderInner = forwardRef(function (_a, ref) {
12
12
  var _b;
13
- var className = _a.className, productLogo = _a.productLogo, konturLogo = _a.konturLogo, iconUrl = _a.iconUrl, style = _a.style, withWidget = _a.withWidget, rest = __rest(_a, ["className", "productLogo", "konturLogo", "iconUrl", "style", "withWidget"]);
13
+ var className = _a.className, productLogo = _a.productLogo, konturLogo = _a.konturLogo, iconUrl = _a.iconUrl, style = _a.style, withWidget = _a.withWidget, dataTid = _a["data-tid"], rest = __rest(_a, ["className", "productLogo", "konturLogo", "iconUrl", "style", "withWidget", 'data-tid']);
14
14
  var context = useContext(SideMenuContext);
15
15
  var theme = getSideMenuTheme(useContext(ThemeContext));
16
16
  var headerWrapperRef = useRef(null);
@@ -20,13 +20,13 @@ var SideMenuHeaderInner = forwardRef(function (_a, ref) {
20
20
  (_a = context.setHeaderHeight) === null || _a === void 0 ? void 0 : _a.call(context, getDOMRect(headerWrapperRef.current).height);
21
21
  }
22
22
  }, []);
23
- return (React.createElement("header", __assign({ className: cx((_b = {},
23
+ return (React.createElement("header", { className: cx((_b = {},
24
24
  _b[jsStyles.root(theme)] = true,
25
25
  _b[jsStyles.rootForTabletsOrMobiles(theme)] = context.isMobile || context.isTablet,
26
26
  _b[jsStyles.fixedRoot(theme)] = context.isShown && !(context.scrollState === 'top'),
27
27
  _b[jsStyles.collapsedRootForTabletsOrMobiles()] = !context.isShown || context.isBeingTransitioned,
28
28
  _b[jsStyles.rootWithSeparatedMenuShown(theme)] = context.isShown && context.isMobile && context.isSeparatedMenuShown,
29
- _b), className), ref: mergeRefs([headerWrapperRef, ref]), style: style }, rest),
29
+ _b), className), ref: mergeRefs([headerWrapperRef, ref]), style: style, "data-tid": dataTid },
30
30
  React.createElement(SideMenuLogotype, __assign({ productLogo: productLogo, konturLogo: konturLogo, iconUrl: iconUrl, withWidget: withWidget }, rest))));
31
31
  });
32
32
  SideMenuHeaderInner.displayName = 'SideMenuHeader';
@@ -3,7 +3,6 @@ import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
3
3
  import { jsStyles } from './Caption.styles';
4
4
  import React, { forwardRef, useContext, useEffect, useRef, useState } from 'react';
5
5
  import { SideMenuContext } from '../../SideMenuContext';
6
- import { mergeRefs } from '@skbkontur/react-ui/lib/utils';
7
6
  import { getSideMenuTheme } from '../../../lib/theming/ThemeHelpers';
8
7
  var getTruncatedUserName = function (caption, visibleWidth, fullWidth) {
9
8
  var _a = caption.split(' '), firstName = _a[0], lastName = _a[1];
@@ -25,7 +24,7 @@ export var Caption = forwardRef(function (_a, ref) {
25
24
  var _b, _c;
26
25
  var _isSubMenu = _a._isSubMenu, _isNestedSubMenu = _a._isNestedSubMenu, hasIcon = _a.hasIcon, caption = _a.caption, subCaption = _a.subCaption, isMultiline = _a.isMultiline, _isBackButton = _a._isBackButton, _isDropdown = _a._isDropdown, _isAvatar = _a._isAvatar;
27
26
  var theme = getSideMenuTheme(useContext(ThemeContext));
28
- var _d = useContext(SideMenuContext), isBeingTransitioned = _d.isBeingTransitioned, isSeparatedMenu = _d.isSeparatedMenu, size = _d.size, isTouchScreen = _d.isTouchScreen, hasSubIcons = _d.hasSubIcons, isTablet = _d.isTablet, isMobile = _d.isMobile;
27
+ var _d = useContext(SideMenuContext), isBeingTransitioned = _d.isBeingTransitioned, isSeparatedMenu = _d.isSeparatedMenu, size = _d.size, isTouchScreen = _d.isTouchScreen, hasSubIcons = _d.hasSubIcons;
29
28
  var captionRef = useRef(null);
30
29
  var _e = useState(''), tail = _e[0], setTail = _e[1];
31
30
  useEffect(function () {
@@ -48,7 +47,6 @@ export var Caption = forwardRef(function (_a, ref) {
48
47
  };
49
48
  return (React.createElement("div", { className: cx((_b = {},
50
49
  _b[jsStyles.root()] = true,
51
- _b[jsStyles.rootBeingTransitioned()] = isBeingTransitioned && !_isSubMenu && !(isTablet || isMobile),
52
50
  _b[jsStyles.rootMultiline()] = isMultiline && !_isSubMenu,
53
51
  _b)), ref: ref },
54
52
  React.createElement("p", { className: cx((_c = {},
@@ -64,7 +62,7 @@ export var Caption = forwardRef(function (_a, ref) {
64
62
  _c[jsStyles.captionForTouchScreens(theme)] = isTouchScreen,
65
63
  _c[jsStyles.captionSubItemForTouchScreens(theme)] = isTouchScreen && _isSubMenu,
66
64
  _c[jsStyles.captionInBackButton(theme)] = _isBackButton,
67
- _c)), ref: mergeRefs([ref, captionRef]), "data-tail": tail }, caption),
65
+ _c)), ref: captionRef, "data-tail": tail }, caption),
68
66
  subCaption));
69
67
  });
70
68
  Caption.displayName = 'Caption';
@@ -3,7 +3,6 @@ export declare const sideMenuMultilineCaptionPaddingTop = "4px";
3
3
  export declare const sideMenuCaptionMarginRight = "8px";
4
4
  export declare const jsStyles: {
5
5
  root(): string;
6
- rootBeingTransitioned(): string;
7
6
  rootMultiline(): string;
8
7
  caption(t: SideMenuTheme): string;
9
8
  captionForTouchScreens(t: SideMenuTheme): string;
@@ -7,48 +7,45 @@ var styles = {
7
7
  root: function () {
8
8
  return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n flex: 1;\n overflow: hidden;\n "], ["\n display: flex;\n flex-direction: column;\n flex: 1;\n overflow: hidden;\n "])));
9
9
  },
10
- rootBeingTransitioned: function () {
11
- return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n white-space: nowrap;\n overflow-x: hidden;\n text-overflow: ellipsis;\n "], ["\n white-space: nowrap;\n overflow-x: hidden;\n text-overflow: ellipsis;\n "])));
12
- },
13
10
  rootMultiline: function () {
14
- return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding-top: ", ";\n align-self: flex-start;\n "], ["\n padding-top: ", ";\n align-self: flex-start;\n "])), sideMenuMultilineCaptionPaddingTop);
11
+ return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding-top: ", ";\n align-self: flex-start;\n "], ["\n padding-top: ", ";\n align-self: flex-start;\n "])), sideMenuMultilineCaptionPaddingTop);
15
12
  },
16
13
  caption: function (t) {
17
- return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n margin: 0 ", " 0 0;\n overflow-wrap: anywhere;\n "], ["\n font-size: ", ";\n line-height: ", ";\n margin: 0 ", " 0 0;\n overflow-wrap: anywhere;\n "])), t.sideMenuCaptionFontSize, t.sideMenuCaptionLineHeight, sideMenuCaptionMarginRight);
14
+ return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n margin: 0 ", " 0 0;\n overflow-wrap: anywhere;\n "], ["\n font-size: ", ";\n line-height: ", ";\n margin: 0 ", " 0 0;\n overflow-wrap: anywhere;\n "])), t.sideMenuCaptionFontSize, t.sideMenuCaptionLineHeight, sideMenuCaptionMarginRight);
18
15
  },
19
16
  captionForTouchScreens: function (t) {
20
- return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-size: ", ";\n line-height: ", ";\n "])), t.sideMenuCaptionFontSizeForTouchScreens, t.sideMenuCaptionLineHeightForTouchScreens);
17
+ return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-size: ", ";\n line-height: ", ";\n "])), t.sideMenuCaptionFontSizeForTouchScreens, t.sideMenuCaptionLineHeightForTouchScreens);
21
18
  },
22
19
  captionSubItem: function (t) {
23
- return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n margin-left: ", ";\n "], ["\n margin-left: ", ";\n "])), t.sideMenuCaptionSubItemMarginLeft);
20
+ return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n margin-left: ", ";\n "], ["\n margin-left: ", ";\n "])), t.sideMenuCaptionSubItemMarginLeft);
24
21
  },
25
22
  captionSubItemForTouchScreens: function (t) {
26
- return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-size: ", ";\n line-height: ", ";\n "])), t.sideMenuCaptionSubItemFontSizeForTouchScreens, t.sideMenuCaptionSubItemLineHeightForTouchScreens);
23
+ return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-size: ", ";\n line-height: ", ";\n "])), t.sideMenuCaptionSubItemFontSizeForTouchScreens, t.sideMenuCaptionSubItemLineHeightForTouchScreens);
27
24
  },
28
25
  captionSubItemSeparatedMenuTopLevel: function () {
29
- return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n margin: 0 8px;\n "], ["\n margin: 0 8px;\n "])));
26
+ return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n margin: 0 8px;\n "], ["\n margin: 0 8px;\n "])));
30
27
  },
31
28
  captionNestedItemSeparatedMenu: function () {
32
- return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n margin-left: 25px;\n "], ["\n margin-left: 25px;\n "])));
29
+ return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n margin-left: 25px;\n "], ["\n margin-left: 25px;\n "])));
33
30
  },
34
31
  captionWithoutItemIcon: function () {
35
- return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n margin-left: 40px;\n "], ["\n margin-left: 40px;\n "])));
32
+ return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n margin-left: 40px;\n "], ["\n margin-left: 40px;\n "])));
36
33
  },
37
34
  captionSubItemWithoutColumnIcons: function () {
38
- return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n margin-left: 8px;\n "], ["\n margin-left: 8px;\n "])));
35
+ return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n margin-left: 8px;\n "], ["\n margin-left: 8px;\n "])));
39
36
  },
40
37
  captionLarge: function (t) {
41
- return css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n font-size: ", " !important;\n line-height: ", " !important;\n "], ["\n font-size: ", " !important;\n line-height: ", " !important;\n "])), t.sideMenuCaptionLargeFontSize, t.sideMenuCaptionLargeLineHeight);
38
+ return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n font-size: ", " !important;\n line-height: ", " !important;\n "], ["\n font-size: ", " !important;\n line-height: ", " !important;\n "])), t.sideMenuCaptionLargeFontSize, t.sideMenuCaptionLargeLineHeight);
42
39
  },
43
40
  captionInBackButton: function (t) {
44
- return css(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n "], ["\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n "])), t.sideMenuBackButtonCaptionFontWeight, t.sideMenuBackButtonCaptionFontSize, t.sideMenuBackButtonCaptionLineHeight, t.sideMenuBackButtonCaptionPaddingY, t.sideMenuBackButtonCaptionPaddingY);
41
+ return css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n "], ["\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n "])), t.sideMenuBackButtonCaptionFontWeight, t.sideMenuBackButtonCaptionFontSize, t.sideMenuBackButtonCaptionLineHeight, t.sideMenuBackButtonCaptionPaddingY, t.sideMenuBackButtonCaptionPaddingY);
45
42
  },
46
43
  captionDropdown: function () {
47
- return css(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n white-space: nowrap;\n overflow: hidden;\n "], ["\n white-space: nowrap;\n overflow: hidden;\n "])));
44
+ return css(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n white-space: nowrap;\n overflow: hidden;\n "], ["\n white-space: nowrap;\n overflow: hidden;\n "])));
48
45
  },
49
46
  captionTruncated: function () {
50
- return css(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n text-overflow: ellipsis;\n &::before {\n float: right;\n content: attr(data-tail);\n }\n "], ["\n text-overflow: ellipsis;\n &::before {\n float: right;\n content: attr(data-tail);\n }\n "])));
47
+ return css(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n text-overflow: ellipsis;\n &::before {\n float: right;\n content: attr(data-tail);\n }\n "], ["\n text-overflow: ellipsis;\n &::before {\n float: right;\n content: attr(data-tail);\n }\n "])));
51
48
  },
52
49
  };
53
50
  export var jsStyles = memoizeStyle(styles);
54
- 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;
51
+ 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;
@@ -1,19 +1,12 @@
1
1
  import React, { forwardRef, useContext, useEffect, useRef, useState } from 'react';
2
2
  import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
3
- import { customStyles, jsStyles } from './ItemContent.styles';
3
+ import { jsStyles } from './ItemContent.styles';
4
4
  import { SideMenuContext } from '../../SideMenuContext';
5
- import { useNumberOfTextLinesInItem } from '../../../hooks/useNumberOfTextLinesInItem';
6
- import { useNumberOfTextLinesInSubItem } from '../../../hooks/useNumberOfTextLinesInSubItem';
7
5
  import { Icon } from './Icon';
8
6
  import { Caption } from './Caption';
9
7
  import { Marker } from './Marker';
10
8
  import { getSideMenuTheme } from '../../../lib/theming/ThemeHelpers';
11
9
  import { ThemeContext } from '@skbkontur/react-ui';
12
- import { sideMenuMultilineCaptionPaddingTop } from './Caption.styles';
13
- var getItemContentHeight = function (theme, linesNumber, size) {
14
- var lineHeight = size === 'large' ? parseInt(theme.sideMenuLargeLineHeight) : parseInt(theme.sideMenuLineHeight);
15
- return linesNumber * lineHeight + parseInt(sideMenuMultilineCaptionPaddingTop);
16
- };
17
10
  /**
18
11
  * Контент для SideMenuItem или SideMenuLink
19
12
  */
@@ -23,58 +16,35 @@ var ItemContent = forwardRef(function (_a, ref) {
23
16
  var context = useContext(SideMenuContext);
24
17
  var size = context.size, isTouchScreen = context.isTouchScreen;
25
18
  var textRef = useRef(null);
26
- var _d = useState(1), linesNumber = _d[0], setLinesNumber = _d[1];
27
- var _e = useState(false), isMultilineSubItem = _e[0], setMultilineSubItem = _e[1];
28
- var isMultiline = (!_isSubMenu && linesNumber > 1) || (!!_isSubMenu && isMultilineSubItem) || !!subCaption;
19
+ var _d = useState(false), isMultiline = _d[0], setIsMultiline = _d[1];
29
20
  var theme = getSideMenuTheme(useContext(ThemeContext));
30
21
  useEffect(function () {
31
- if (!_isBackButton && !_isSubMenu && !_isDropdown) {
32
- useNumberOfTextLinesInItem({
33
- textRef: textRef,
34
- setLinesNumber: setLinesNumber,
35
- theme: theme,
36
- caption: caption,
37
- marker: marker,
38
- size: size,
39
- isTouchScreen: isTouchScreen,
40
- });
22
+ if (!textRef.current || _isBackButton)
23
+ return;
24
+ var text = textRef.current.querySelector('p');
25
+ if ((text && parseInt(getComputedStyle(text).lineHeight) < text.clientHeight) || subCaption) {
26
+ setIsMultiline(true);
41
27
  }
42
- if (!_isBackButton && _isSubMenu) {
43
- useNumberOfTextLinesInSubItem(textRef, setMultilineSubItem, size, theme);
44
- }
45
- }, [caption]);
46
- useEffect(function () {
47
- if (!_isBackButton && !_isDropdown) {
48
- useNumberOfTextLinesInItem({
49
- textRef: textRef,
50
- setLinesNumber: setLinesNumber,
51
- theme: theme,
52
- caption: caption,
53
- marker: marker,
54
- size: size,
55
- isTouchScreen: isTouchScreen,
56
- });
57
- }
58
- }, [textRef.current, context.isBeingTransitioned]);
28
+ });
59
29
  var isSeparatedSubMenuInNarrowDesktop = _isSubMenu && context.isSeparatedMenu && context.isNarrowDesktop;
60
30
  return (React.createElement("div", { className: cx((_b = {},
61
31
  _b[jsStyles.root(theme)] = true,
62
32
  _b[jsStyles.subItemRoot(theme)] = _isSubMenu,
63
33
  _b[jsStyles.largeRoot(theme)] = size === 'large' && !_isSubMenu,
64
34
  _b[jsStyles.subItemLargeRoot(theme)] = size === 'large' && _isSubMenu,
65
- _b[jsStyles.multilineRoot(theme)] = isMultiline && !_isSubMenu,
35
+ _b[jsStyles.multilineRoot(theme)] = isMultiline && !_isSubMenu && !context.isMinimized,
66
36
  _b[jsStyles.largeMultilineRoot(theme)] = isMultiline && size === 'large',
67
37
  _b[jsStyles.rootForTouchScreens(theme)] = isTouchScreen,
68
38
  _b[jsStyles.subItemRootForTouchScreens(theme)] = isTouchScreen && _isSubMenu,
69
39
  _b)), ref: ref },
70
40
  icon && (React.createElement(Icon, { icon: icon, _isSubMenu: _isSubMenu, isMultiline: isMultiline, _isBackButton: _isBackButton, _isAvatar: _isAvatar })),
71
- (!context.isMinimized || (context.isMinimized && _isSubMenu)) && (React.createElement("div", { className: cx((_c = {},
41
+ React.createElement("div", { className: cx((_c = {},
72
42
  _c[jsStyles.textAndMarkerWrapper()] = true,
73
43
  _c[jsStyles.textAndMarkerWrapperDropdown()] = _isDropdown,
74
- _c[customStyles.textAndMarkerWrapperMultiline(getItemContentHeight(theme, linesNumber, size))] = isMultiline && !_isSubMenu,
44
+ _c[jsStyles.textAndMarkerWrapperMinimized()] = context.isMinimized && !_isSubMenu,
75
45
  _c)) },
76
46
  React.createElement(Caption, { _isSubMenu: _isSubMenu, _isNestedSubMenu: _isNestedSubMenu, hasIcon: !!icon, isMultiline: isMultiline, caption: caption, subCaption: subCaption, _isBackButton: _isBackButton, _isDropdown: _isDropdown, _isAvatar: _isAvatar, ref: textRef }),
77
- marker !== undefined && (!context.isMinimized || isSeparatedSubMenuInNarrowDesktop) && (React.createElement(Marker, { isMultiline: isMultiline, marker: marker, _isSubMenu: _isSubMenu }))))));
47
+ marker !== undefined && (!context.isMinimized || isSeparatedSubMenuInNarrowDesktop) && (React.createElement(Marker, { isMultiline: isMultiline, marker: marker, _isSubMenu: _isSubMenu })))));
78
48
  });
79
49
  ItemContent.displayName = 'ItemContent';
80
50
  var ItemContentWithStaticFields = Object.assign(ItemContent, { __KONTUR_REACT_UI__: 'ItemContent' });
@@ -1,7 +1,4 @@
1
1
  import { SideMenuTheme } from '../../../lib/theming/ThemeTypes';
2
- export declare const customStyles: {
3
- textAndMarkerWrapperMultiline(height: number): string;
4
- };
5
2
  export declare const jsStyles: {
6
3
  root(t: SideMenuTheme): string;
7
4
  largeRoot(t: SideMenuTheme): string;
@@ -13,4 +10,5 @@ export declare const jsStyles: {
13
10
  subItemRoot(t: SideMenuTheme): string;
14
11
  textAndMarkerWrapper(): string;
15
12
  textAndMarkerWrapperDropdown(): string;
13
+ textAndMarkerWrapperMinimized(): string;
16
14
  };
@@ -32,10 +32,8 @@ var styles = {
32
32
  textAndMarkerWrapperDropdown: function () {
33
33
  return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n overflow: hidden;\n "], ["\n overflow: hidden;\n "])));
34
34
  },
35
- };
36
- export var customStyles = {
37
- textAndMarkerWrapperMultiline: function (height) {
38
- return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n min-height: ", "px;\n "], ["\n min-height: ", "px;\n "])), height);
35
+ textAndMarkerWrapperMinimized: function () {
36
+ return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n display: none;\n "], ["\n display: none;\n "])));
39
37
  },
40
38
  };
41
39
  export var jsStyles = memoizeStyle(styles);
@@ -9,19 +9,19 @@ var styles = {
9
9
  return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n "], ["\n display: flex;\n "])));
10
10
  },
11
11
  icon: function () {
12
- return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n left: 0;\n opacity: 1;\n "], ["\n left: 0;\n opacity: 1;\n "])));
12
+ return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n opacity: 1;\n width: auto;\n "], ["\n opacity: 1;\n width: auto;\n "])));
13
13
  },
14
14
  iconHidden: function (t) {
15
- return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: relative;\n left: -", ";\n display: block;\n padding-left: ", ";\n opacity: 0;\n transition: all ", "ms ease-out;\n "], ["\n position: relative;\n left: -", ";\n display: block;\n padding-left: ", ";\n opacity: 0;\n transition: all ", "ms ease-out;\n "])), sideMenuLogotypeGapBetweenIconAndLogo, t.sideMenuLogotypeHiddenIconPaddingLeft, transitionDuration);
15
+ return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: block;\n width: 0;\n padding-left: ", ";\n opacity: 0;\n transition: all ", "ms ease-out;\n "], ["\n display: block;\n width: 0;\n padding-left: ", ";\n opacity: 0;\n transition: all ", "ms ease-out;\n "])), t.sideMenuLogotypeHiddenIconPaddingLeft, transitionDuration);
16
16
  },
17
17
  logoWrapper: function (t) {
18
- return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: relative;\n left: -", ";\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n display: flex;\n opacity: 1;\n transition: all ", "ms ease-out;\n "], ["\n position: relative;\n left: -", ";\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n display: flex;\n opacity: 1;\n transition: all ", "ms ease-out;\n "])), sideMenuLogotypeIconSize, t.sideMenuLogotypePaddingTop, t.sideMenuLogotypePaddingBottom, t.sideMenuLogotypePaddingLeft, transitionDuration);
18
+ return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n display: flex;\n opacity: 1;\n transition: all ", "ms ease-out;\n "], ["\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n display: flex;\n opacity: 1;\n transition: all ", "ms ease-out;\n "])), t.sideMenuLogotypePaddingTop, t.sideMenuLogotypePaddingBottom, t.sideMenuLogotypePaddingLeft, transitionDuration);
19
19
  },
20
20
  logoWrapperForTabletsOrMobiles: function (t) {
21
- return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n padding-top: ", ";\n padding-bottom: ", ";\n left: 0;\n "], ["\n padding-top: ", ";\n padding-bottom: ", ";\n left: 0;\n "])), t.sideMenuLogotypePaddingYForTouchScreens, t.sideMenuLogotypePaddingYForTouchScreens);
21
+ return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n padding-top: ", ";\n padding-bottom: ", ";\n "], ["\n padding-top: ", ";\n padding-bottom: ", ";\n "])), t.sideMenuLogotypePaddingYForTouchScreens, t.sideMenuLogotypePaddingYForTouchScreens);
22
22
  },
23
23
  logoWrapperHidden: function () {
24
- return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n left: ", "px;\n opacity: 0;\n "], ["\n left: ", "px;\n opacity: 0;\n "])), parseInt(sideMenuLogotypeGapBetweenIconAndLogo) - parseInt(sideMenuLogotypeIconSize));
24
+ return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n opacity: 0;\n "], ["\n opacity: 0;\n "])));
25
25
  },
26
26
  };
27
27
  export var jsStyles = memoizeStyle(styles);
@@ -1,13 +0,0 @@
1
- import React from 'react';
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 | boolean;
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,64 +0,0 @@
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, theme, marker, isTouchScreen) {
20
- var containerWidth = parseInt(isTouchScreen ? theme.sideMenuWidthForTouchScreens : theme.sideMenuWidth) -
21
- 2 * parseInt(theme.sideMenuMarginX) -
22
- parseInt(theme.sideMenuIconSize) -
23
- 2 * parseInt(theme.sideMenuIconMarginX);
24
- var markerPaddings = marker
25
- ? 2 * parseInt(theme.sideMenuMarkerPaddingX) + parseInt(theme.sideMenuMarkerMarginRight)
26
- : 0;
27
- var emptyMarker = marker === true || marker === '';
28
- var markerWidth;
29
- if (emptyMarker) {
30
- markerWidth = 8;
31
- }
32
- else if (typeof marker === 'string') {
33
- markerWidth = ctx.measureText(marker).width + markerPaddings;
34
- }
35
- else {
36
- markerWidth = 0;
37
- }
38
- return containerWidth - markerWidth - parseInt(sideMenuCaptionMarginRight);
39
- };
40
- var getFontSize = function (theme, isTouchScreen, size) {
41
- if (size !== 'small') {
42
- return parseInt(theme.sideMenuCaptionLargeFontSize);
43
- }
44
- if (isTouchScreen) {
45
- return parseInt(theme.sideMenuCaptionFontSizeForTouchScreens);
46
- }
47
- else {
48
- return parseInt(theme.sideMenuCaptionFontSize);
49
- }
50
- };
51
- export var useNumberOfTextLinesInItem = function (_a) {
52
- var textRef = _a.textRef, setLinesNumber = _a.setLinesNumber, theme = _a.theme, _b = _a.caption, caption = _b === void 0 ? '' : _b, marker = _a.marker, size = _a.size, isTouchScreen = _a.isTouchScreen;
53
- var fontSize = getFontSize(theme, isTouchScreen, size);
54
- var fontFamily = textRef.current && isBrowser
55
- ? window.getComputedStyle(textRef.current).getPropertyValue('font-family')
56
- : "'Lab Grotesque', 'Segoe UI', 'Helvetica Neue', Roboto, Arial, sans-serif";
57
- var canvas = document.createElement('canvas');
58
- var ctx = canvas.getContext('2d');
59
- if (ctx) {
60
- ctx.font = fontSize + "px " + fontFamily;
61
- var words = caption.split(' ');
62
- setLinesNumber(getNumberOfLines(ctx, words, getContainerWidth(ctx, theme, marker, isTouchScreen)));
63
- }
64
- };
@@ -1,3 +0,0 @@
1
- import React from 'react';
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,14 +0,0 @@
1
- export var useNumberOfTextLinesInSubItem = function (textRef, setIsMultilineText, size, theme) {
2
- if (size === void 0) { size = 'small'; }
3
- if (textRef.current) {
4
- var el_1 = textRef.current;
5
- setTimeout(function () {
6
- var textHeight = +el_1.offsetHeight;
7
- var lineHeight = size === 'small' ? parseInt(theme.sideMenuLineHeight) : parseInt(theme.sideMenuLargeLineHeight);
8
- var lines = textHeight / lineHeight;
9
- if (lines >= 2) {
10
- setIsMultilineText(true);
11
- }
12
- }, 0);
13
- }
14
- };