@skbkontur/side-menu 0.7.3 → 0.8.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 (47) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/hooks/useAnimateOnMount.d.ts +2 -0
  3. package/hooks/useAnimateOnMount.js +18 -0
  4. package/hooks/useNumberOfTextLinesInItem.d.ts +1 -1
  5. package/hooks/useNumberOfTextLinesInItem.js +35 -10
  6. package/hooks/useNumberOfTextLinesInSubItem.d.ts +2 -0
  7. package/hooks/useNumberOfTextLinesInSubItem.js +13 -0
  8. package/package.json +3 -3
  9. package/src/SideMenu/SideMenu.d.ts +2 -0
  10. package/src/SideMenu/SideMenu.js +65 -55
  11. package/src/SideMenu/SideMenu.styles.d.ts +1 -3
  12. package/src/SideMenu/SideMenu.styles.js +15 -22
  13. package/src/SideMenuBody/SideMenuBody.d.ts +2 -1
  14. package/src/SideMenuBody/SideMenuBody.js +24 -3
  15. package/src/SideMenuBody/SideMenuBody.styles.js +2 -1
  16. package/src/SideMenuContext.d.ts +5 -2
  17. package/src/SideMenuDropdown/SideMenuDropdown.js +26 -23
  18. package/src/SideMenuDropdown/SideMenuDropdown.styles.js +2 -1
  19. package/src/SideMenuFooter/SideMenuFooter.d.ts +1 -1
  20. package/src/SideMenuFooter/SideMenuFooter.js +10 -2
  21. package/src/SideMenuFooter/SideMenuFooter.styles.d.ts +2 -0
  22. package/src/SideMenuFooter/SideMenuFooter.styles.js +9 -2
  23. package/src/SideMenuHeader/SideMenuHeader.js +4 -23
  24. package/src/SideMenuHeader/SideMenuHeader.styles.d.ts +1 -0
  25. package/src/SideMenuHeader/SideMenuHeader.styles.js +10 -7
  26. package/src/internal/Backdrop.d.ts +4 -1
  27. package/src/internal/Backdrop.js +3 -5
  28. package/src/internal/Backdrop.styles.js +2 -1
  29. package/src/internal/ClickableElement.styles.js +1 -1
  30. package/src/internal/ItemContent/Caption.js +2 -2
  31. package/src/internal/ItemContent/Caption.styles.js +1 -1
  32. package/src/internal/ItemContent/Icon.js +1 -2
  33. package/src/internal/ItemContent/Icon.styles.d.ts +0 -1
  34. package/src/internal/ItemContent/Icon.styles.js +6 -9
  35. package/src/internal/ItemContent/ItemContent.js +24 -7
  36. package/src/internal/ItemContent/ItemContent.styles.d.ts +4 -1
  37. package/src/internal/ItemContent/ItemContent.styles.js +18 -11
  38. package/src/internal/ItemContent/Marker.styles.js +1 -1
  39. package/src/internal/SeparatedSubMenu.js +26 -20
  40. package/src/internal/SeparatedSubMenu.styles.d.ts +2 -0
  41. package/src/internal/SeparatedSubMenu.styles.js +9 -3
  42. package/src/internal/SideMenuLogotype.js +14 -6
  43. package/src/internal/SideMenuLogotype.styles.d.ts +5 -1
  44. package/src/internal/SideMenuLogotype.styles.js +19 -4
  45. package/src/internal/SubMenu.js +1 -1
  46. package/hooks/useMobileSeparatedMenuScroll.d.ts +0 -1
  47. package/hooks/useMobileSeparatedMenuScroll.js +0 -21
@@ -3,11 +3,11 @@ import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
3
3
  import { sideMenuBoxShadow, sideMenuMinimizedWidth, sideMenuStandardWidth } from '../SideMenu/SideMenu.styles';
4
4
  var styles = {
5
5
  root: function () {
6
- return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n z-index: 8000;\n background: #fff;\n left: 100%;\n overflow: auto;\n justify-content: flex-start;\n padding: 24px 16px;\n border-right: 1px solid #e5e5e5;\n "], ["\n position: absolute;\n top: 0;\n z-index: 8000;\n background: #fff;\n left: 100%;\n overflow: auto;\n justify-content: flex-start;\n padding: 24px 16px;\n border-right: 1px solid #e5e5e5;\n "])));
6
+ return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n z-index: 8000;\n background: #fff;\n left: 100%;\n overflow: auto;\n justify-content: flex-start;\n border-right: 1px solid #e5e5e5;\n "], ["\n position: absolute;\n top: 0;\n z-index: 8000;\n background: #fff;\n left: 100%;\n overflow: auto;\n justify-content: flex-start;\n border-right: 1px solid #e5e5e5;\n "])));
7
7
  },
8
8
  rootForMobiles: function () {
9
9
  var headerHeight = '68px';
10
- return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n height: calc(100vh - ", ");\n left: 0;\n top: ", ";\n padding-top: 0;\n "], ["\n height: calc(100vh - ", ");\n left: 0;\n top: ", ";\n padding-top: 0;\n "])), headerHeight, headerHeight);
10
+ return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n height: calc(100vh - ", ");\n left: 0;\n top: ", ";\n "], ["\n height: calc(100vh - ", ");\n left: 0;\n top: ", ";\n "])), headerHeight, headerHeight);
11
11
  },
12
12
  rootWithoutOverlayForNarrowDesktop: function () {
13
13
  return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n left: ", ";\n z-index: -1;\n "], ["\n left: ", ";\n z-index: -1;\n "])), sideMenuMinimizedWidth);
@@ -18,6 +18,12 @@ var styles = {
18
18
  rootWithShadow: function () {
19
19
  return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n box-shadow: ", ";\n clip-path: inset(0 -24px 0 0);\n border-right: none;\n "], ["\n box-shadow: ", ";\n clip-path: inset(0 -24px 0 0);\n border-right: none;\n "])), sideMenuBoxShadow);
20
20
  },
21
+ contentWrapper: function () {
22
+ return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding: 24px 16px;\n "], ["\n padding: 24px 16px;\n "])));
23
+ },
24
+ contentWrapperForMobiles: function () {
25
+ return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n padding-top: 0;\n "], ["\n padding-top: 0;\n "])));
26
+ },
21
27
  };
22
28
  export var jsStylesForSeparatedSubMenu = memoizeStyle(styles);
23
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
29
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
@@ -4,16 +4,18 @@ import { Logotype } from '@skbkontur/react-ui-addons/components/Logotype';
4
4
  import { jsStyles } from './SideMenuLogotype.styles';
5
5
  import { SideMenuContext } from '../SideMenuContext';
6
6
  import { Burger } from './Burger';
7
+ import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
7
8
  /**
8
9
  * Логотип
9
10
  *
10
11
  * @visibleName SideMenu.Logotype
11
12
  */
12
13
  var SideMenuLogotype = forwardRef(function (_a, ref) {
14
+ var _b, _c;
13
15
  var productLogo = _a.productLogo, withWidget = _a.withWidget, konturLogo = _a.konturLogo, iconUrl = _a.iconUrl, rest = __rest(_a, ["productLogo", "withWidget", "konturLogo", "iconUrl"]);
14
16
  var context = useContext(SideMenuContext);
15
17
  var refLogotype = useRef(null);
16
- var _b = useState(28), size = _b[0], setSize = _b[1];
18
+ var _d = useState(28), size = _d[0], setSize = _d[1];
17
19
  useEffect(function () {
18
20
  var _a, _b, _c;
19
21
  (_a = context.setProductColor) === null || _a === void 0 ? void 0 : _a.call(context, productLogo === null || productLogo === void 0 ? void 0 : productLogo.props.color);
@@ -42,9 +44,6 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
42
44
  var getStaticIconPath = function () {
43
45
  return "https://s.kontur.ru/common-v2/icons-products/" + productName + "/" + productName + "-32.svg";
44
46
  };
45
- if (context.isMinimized || context.isBeingTransitioned) {
46
- return React.createElement("img", { className: jsStyles.icon(), src: iconUrl || getStaticIconPath(), alt: productName });
47
- }
48
47
  var getWidget = function (withWidget, isTouchScreen, showWidget) {
49
48
  if (withWidget !== undefined) {
50
49
  return withWidget;
@@ -55,8 +54,17 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
55
54
  return showWidget;
56
55
  };
57
56
  return (React.createElement("div", { className: jsStyles.root(), ref: ref },
58
- (context.isTablet || context.isMobile) && React.createElement(Burger, null),
59
- React.createElement(Logotype, __assign({ ref: refLogotype, size: size, productLogo: productLogo, konturLogo: konturLogo, withWidget: getWidget(withWidget, context.isTouchScreen, context.showWidget) }, rest))));
57
+ !context.isMobile && !context.isTablet && (React.createElement("img", { className: cx((_b = {},
58
+ _b[jsStyles.iconHidden()] = true,
59
+ _b[jsStyles.icon()] = context.isMinimized,
60
+ _b)), src: iconUrl || getStaticIconPath(), alt: productName })),
61
+ React.createElement("div", { className: cx((_c = {},
62
+ _c[jsStyles.logoWrapper()] = true,
63
+ _c[jsStyles.logoWrapperForTabletsOrMobiles()] = context.isMobile || context.isTablet,
64
+ _c[jsStyles.logoWrapperHidden()] = context.isMinimized,
65
+ _c)) },
66
+ (context.isTablet || context.isMobile) && React.createElement(Burger, null),
67
+ React.createElement(Logotype, __assign({ ref: refLogotype, size: size, productLogo: productLogo, konturLogo: konturLogo, withWidget: getWidget(withWidget, context.isTouchScreen, context.showWidget) }, rest)))));
60
68
  });
61
69
  SideMenuLogotype.displayName = 'SideMenuLogotype';
62
70
  var SideMenuLogotypeWithStaticFields = Object.assign(SideMenuLogotype, { __KONTUR_REACT_UI__: 'SideMenuLogotype' });
@@ -1,4 +1,8 @@
1
1
  export declare const jsStyles: {
2
- icon(): string;
3
2
  root(): string;
3
+ icon(): string;
4
+ iconHidden(): string;
5
+ logoWrapper(): string;
6
+ logoWrapperForTabletsOrMobiles(): string;
7
+ logoWrapperHidden(): string;
4
8
  };
@@ -1,12 +1,27 @@
1
1
  import { __makeTemplateObject } from "tslib";
2
2
  import { css, memoizeStyle } from '@skbkontur/react-ui/lib/theming/Emotion';
3
+ import { transitionDuration } from '../SideMenu/SideMenu';
4
+ var iconSize = 32;
5
+ var gapBetweenIconAndLogo = 50;
3
6
  var styles = {
7
+ root: function () {
8
+ return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n "], ["\n display: flex;\n "])));
9
+ },
4
10
  icon: function () {
5
- return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 0 4px;\n "], ["\n padding: 0 4px;\n "])));
11
+ return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n left: 0;\n opacity: 1;\n "], ["\n left: 0;\n opacity: 1;\n "])));
6
12
  },
7
- root: function () {
8
- return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n "], ["\n display: flex;\n "])));
13
+ iconHidden: function () {
14
+ return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: relative;\n left: -", "px;\n display: block;\n padding-left: 4px;\n opacity: 0;\n transition: all ", "ms ease-out;\n "], ["\n position: relative;\n left: -", "px;\n display: block;\n padding-left: 4px;\n opacity: 0;\n transition: all ", "ms ease-out;\n "])), gapBetweenIconAndLogo, transitionDuration);
15
+ },
16
+ logoWrapper: function () {
17
+ return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: relative;\n left: -", "px;\n padding-top: 2px;\n padding-bottom: 6px;\n padding-left: 8px;\n display: flex;\n opacity: 1;\n transition: all ", "ms ease-out;\n "], ["\n position: relative;\n left: -", "px;\n padding-top: 2px;\n padding-bottom: 6px;\n padding-left: 8px;\n display: flex;\n opacity: 1;\n transition: all ", "ms ease-out;\n "])), iconSize, transitionDuration);
18
+ },
19
+ logoWrapperForTabletsOrMobiles: function () {
20
+ return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n padding-top: 8px;\n padding-bottom: 8px;\n left: 0;\n "], ["\n padding-top: 8px;\n padding-bottom: 8px;\n left: 0;\n "])));
21
+ },
22
+ logoWrapperHidden: function () {
23
+ return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n left: ", "px;\n opacity: 0;\n "], ["\n left: ", "px;\n opacity: 0;\n "])), gapBetweenIconAndLogo - iconSize);
9
24
  },
10
25
  };
11
26
  export var jsStyles = memoizeStyle(styles);
12
- var templateObject_1, templateObject_2;
27
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
@@ -14,7 +14,7 @@ var SubMenu = forwardRef(function (_a, ref) {
14
14
  if (!children || !isOpened || isSubMenu || shouldHideOverlayMenu) {
15
15
  return null;
16
16
  }
17
- if (isSeparatedMenu) {
17
+ if (isSeparatedMenu && (context.isShown || context.isBeingTransitioned)) {
18
18
  return (React.createElement(SeparatedSubMenu, { generatedId: generatedId, id: id, href: href, ref: ref, caption: caption }, children));
19
19
  }
20
20
  return (React.createElement(InnerSubMenu, { generatedId: generatedId, ref: ref }, children));
@@ -1 +0,0 @@
1
- export declare const useMobileSeparatedMenuScroll: () => import("react").RefObject<HTMLDivElement>;
@@ -1,21 +0,0 @@
1
- import { useContext, useEffect, useRef } from 'react';
2
- import { SideMenuContext } from '../src/SideMenuContext';
3
- export var useMobileSeparatedMenuScroll = function () {
4
- var separatedMenuRef = useRef(null);
5
- var context = useContext(SideMenuContext);
6
- var checkScroll = function () {
7
- var _a, _b;
8
- var isScrolledToTop = ((_a = separatedMenuRef.current) === null || _a === void 0 ? void 0 : _a.scrollTop) === 0;
9
- (_b = context.setIsMobileSeparatedMenuScrolling) === null || _b === void 0 ? void 0 : _b.call(context, !isScrolledToTop);
10
- };
11
- useEffect(function () {
12
- var _a;
13
- context.isMobile && ((_a = separatedMenuRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('scroll', checkScroll, true));
14
- return function () {
15
- var _a, _b;
16
- (_a = separatedMenuRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('scroll', checkScroll, true);
17
- (_b = context.setIsMobileSeparatedMenuScrolling) === null || _b === void 0 ? void 0 : _b.call(context, false);
18
- };
19
- }, []);
20
- return separatedMenuRef;
21
- };