@alfalab/core-components-navigation-bar-private 0.1.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 (92) hide show
  1. package/Component.d.ts +5 -0
  2. package/Component.js +165 -0
  3. package/components/back-arrow-addon/Component.d.ts +26 -0
  4. package/components/back-arrow-addon/Component.js +35 -0
  5. package/components/back-arrow-addon/index.css +76 -0
  6. package/components/back-arrow-addon/index.d.ts +1 -0
  7. package/components/back-arrow-addon/index.js +9 -0
  8. package/components/closer/Component.d.ts +35 -0
  9. package/components/closer/Component.js +32 -0
  10. package/components/closer/index.css +48 -0
  11. package/components/closer/index.d.ts +1 -0
  12. package/components/closer/index.js +9 -0
  13. package/cssm/Component.d.ts +5 -0
  14. package/cssm/Component.js +164 -0
  15. package/cssm/components/back-arrow-addon/Component.d.ts +26 -0
  16. package/cssm/components/back-arrow-addon/Component.js +34 -0
  17. package/cssm/components/back-arrow-addon/index.d.ts +1 -0
  18. package/cssm/components/back-arrow-addon/index.js +9 -0
  19. package/cssm/components/back-arrow-addon/index.module.css +75 -0
  20. package/cssm/components/closer/Component.d.ts +35 -0
  21. package/cssm/components/closer/Component.js +31 -0
  22. package/cssm/components/closer/index.d.ts +1 -0
  23. package/cssm/components/closer/index.js +9 -0
  24. package/cssm/components/closer/index.module.css +47 -0
  25. package/cssm/index.d.ts +2 -0
  26. package/cssm/index.js +9 -0
  27. package/cssm/index.module.css +108 -0
  28. package/cssm/shared/index.d.ts +2 -0
  29. package/cssm/shared/index.js +11 -0
  30. package/cssm/types.d.ts +118 -0
  31. package/cssm/types.js +2 -0
  32. package/cssm/vars.css +20 -0
  33. package/esm/Component.d.ts +5 -0
  34. package/esm/Component.js +155 -0
  35. package/esm/components/back-arrow-addon/Component.d.ts +26 -0
  36. package/esm/components/back-arrow-addon/Component.js +26 -0
  37. package/esm/components/back-arrow-addon/index.css +76 -0
  38. package/esm/components/back-arrow-addon/index.d.ts +1 -0
  39. package/esm/components/back-arrow-addon/index.js +1 -0
  40. package/esm/components/closer/Component.d.ts +35 -0
  41. package/esm/components/closer/Component.js +23 -0
  42. package/esm/components/closer/index.css +48 -0
  43. package/esm/components/closer/index.d.ts +1 -0
  44. package/esm/components/closer/index.js +1 -0
  45. package/esm/index.css +108 -0
  46. package/esm/index.d.ts +2 -0
  47. package/esm/index.js +1 -0
  48. package/esm/shared/index.d.ts +2 -0
  49. package/esm/shared/index.js +2 -0
  50. package/esm/types.d.ts +118 -0
  51. package/esm/types.js +1 -0
  52. package/index.css +108 -0
  53. package/index.d.ts +2 -0
  54. package/index.js +9 -0
  55. package/modern/Component.d.ts +5 -0
  56. package/modern/Component.js +160 -0
  57. package/modern/components/back-arrow-addon/Component.d.ts +26 -0
  58. package/modern/components/back-arrow-addon/Component.js +23 -0
  59. package/modern/components/back-arrow-addon/index.css +76 -0
  60. package/modern/components/back-arrow-addon/index.d.ts +1 -0
  61. package/modern/components/back-arrow-addon/index.js +1 -0
  62. package/modern/components/closer/Component.d.ts +35 -0
  63. package/modern/components/closer/Component.js +20 -0
  64. package/modern/components/closer/index.css +48 -0
  65. package/modern/components/closer/index.d.ts +1 -0
  66. package/modern/components/closer/index.js +1 -0
  67. package/modern/index.css +108 -0
  68. package/modern/index.d.ts +2 -0
  69. package/modern/index.js +1 -0
  70. package/modern/shared/index.d.ts +2 -0
  71. package/modern/shared/index.js +2 -0
  72. package/modern/types.d.ts +118 -0
  73. package/modern/types.js +1 -0
  74. package/package.json +27 -0
  75. package/shared/index.d.ts +2 -0
  76. package/shared/index.js +11 -0
  77. package/shared/package.json +3 -0
  78. package/src/Component.tsx +284 -0
  79. package/src/components/back-arrow-addon/Component.tsx +79 -0
  80. package/src/components/back-arrow-addon/index.module.css +69 -0
  81. package/src/components/back-arrow-addon/index.ts +1 -0
  82. package/src/components/closer/Component.tsx +80 -0
  83. package/src/components/closer/index.module.css +32 -0
  84. package/src/components/closer/index.ts +1 -0
  85. package/src/index.module.css +118 -0
  86. package/src/index.ts +2 -0
  87. package/src/shared/index.ts +2 -0
  88. package/src/shared/package.json +3 -0
  89. package/src/types.ts +143 -0
  90. package/src/vars.css +9 -0
  91. package/types.d.ts +118 -0
  92. package/types.js +2 -0
@@ -0,0 +1,48 @@
1
+ /* hash: auqb3 */
2
+ :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
3
+ } /* deprecated */ :root {
4
+ --color-light-neutral-1500: #121213;
5
+ --color-light-neutral-translucent-100: rgba(38, 55, 88, 0.06);
6
+ --color-light-neutral-translucent-700: rgba(4, 4, 21, 0.47); /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
7
+ --color-light-bg-primary-alpha-40: rgba(255, 255, 255, 0.4);
8
+ } :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
9
+ } :root {
10
+ } :root {
11
+
12
+ /* Hard */
13
+
14
+ /* Up */
15
+
16
+ /* Hard up */
17
+ } :root {
18
+ --border-radius-circle: 50%;
19
+ } :root {
20
+ } :root {
21
+ } :root {
22
+ } :root {
23
+ /* closer-mobile */
24
+ --navigation-bar-closer-mobile-color: var(--color-light-neutral-translucent-700);
25
+
26
+ /* back-arrow */
27
+ } .navigation-bar-private__closer_1bwy4 {
28
+ flex-shrink: 0;
29
+ width: 48px;
30
+ height: 48px;
31
+ margin-left: auto;
32
+ display: flex;
33
+ align-items: center;
34
+ justify-content: center;
35
+ } .navigation-bar-private__button_1bwy4 {
36
+ background: var(--color-light-bg-primary-alpha-40);
37
+ -webkit-backdrop-filter: blur(10px);
38
+ backdrop-filter: blur(10px);
39
+ color: var(--color-light-neutral-1500)
40
+ } .navigation-bar-private__button_1bwy4.navigation-bar-private__mobile_1bwy4 {
41
+ background: var(--color-light-neutral-translucent-100);
42
+ color: var(--navigation-bar-closer-mobile-color);
43
+ } .navigation-bar-private__button_1bwy4.navigation-bar-private__button_1bwy4 {
44
+ border-radius: var(--border-radius-circle);
45
+ } .navigation-bar-private__sticky_1bwy4 {
46
+ position: sticky;
47
+ top: 0;
48
+ }
@@ -0,0 +1 @@
1
+ export * from "./Component";
@@ -0,0 +1 @@
1
+ export { Closer } from './Component.js';
@@ -0,0 +1,108 @@
1
+ /* hash: 21se8 */
2
+ :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
3
+ } /* deprecated */ :root {
4
+ --color-light-text-primary: rgba(3, 3, 6, 0.88);
5
+ --color-light-text-secondary: rgba(4, 4, 19, 0.55); /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
6
+ } :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
7
+ } :root {
8
+ } :root {
9
+
10
+ /* Hard */
11
+
12
+ /* Up */
13
+
14
+ /* Hard up */
15
+ } :root {
16
+ } :root {
17
+ --gap-2xs: 4px;
18
+ --gap-s: 12px;
19
+ } :root {
20
+ } :root {
21
+ } .navigation-bar-private__header_16jqi {
22
+ width: 100%;
23
+ box-sizing: border-box;
24
+ transition: box-shadow 0.2s ease, background 0.2s ease
25
+ } .navigation-bar-private__header_16jqi.navigation-bar-private__header_16jqi.navigation-bar-private__backgroundImage_16jqi {
26
+ background-repeat: no-repeat;
27
+ background-position: center;
28
+ background-size: cover;
29
+ } .navigation-bar-private__mainLine_16jqi {
30
+ display: flex;
31
+ align-items: stretch;
32
+ justify-content: space-between;
33
+ z-index: 1;
34
+ background-color: inherit;
35
+ } .navigation-bar-private__mainLineSticky_16jqi {
36
+ position: sticky;
37
+ top: 0;
38
+ } .navigation-bar-private__mainLineWithImageBg_16jqi {
39
+ background-color: initial;
40
+ } .navigation-bar-private__content_16jqi {
41
+ color: var(--color-light-text-primary);
42
+ display: flex;
43
+ flex-flow: column nowrap;
44
+ justify-content: center;
45
+ flex-grow: 1;
46
+ align-self: baseline;
47
+ box-sizing: border-box;
48
+ min-height: 48px
49
+ } .navigation-bar-private__content_16jqi.navigation-bar-private__withBothAddons_16jqi,
50
+ .navigation-bar-private__content_16jqi.navigation-bar-private__withCompactTitle_16jqi {
51
+ font-size: 16px;
52
+ line-height: 20px;
53
+ font-weight: 500;
54
+ align-self: center;
55
+ padding-top: var(--gap-2xs);
56
+ padding-bottom: var(--gap-2xs)
57
+ } .navigation-bar-private__content_16jqi.navigation-bar-private__withBothAddons_16jqi > .navigation-bar-private__children_16jqi,
58
+ .navigation-bar-private__content_16jqi.navigation-bar-private__withBothAddons_16jqi > .navigation-bar-private__title_16jqi,
59
+ .navigation-bar-private__content_16jqi.navigation-bar-private__withCompactTitle_16jqi > .navigation-bar-private__children_16jqi,
60
+ .navigation-bar-private__content_16jqi.navigation-bar-private__withCompactTitle_16jqi > .navigation-bar-private__title_16jqi {
61
+ -webkit-line-clamp: 1;
62
+ word-break: break-all;
63
+ } .navigation-bar-private__content_16jqi.navigation-bar-private__contentOnBotDesktop_16jqi.navigation-bar-private__contentOnBotDesktop_16jqi {
64
+ padding-top: var(--gap-s);
65
+ } .navigation-bar-private__content_16jqi.navigation-bar-private__contentOnBotMobile_16jqi.navigation-bar-private__contentOnBotMobile_16jqi {
66
+ padding-top: var(--gap-s);
67
+ } .navigation-bar-private__title_16jqi {
68
+ word-break: break-word;
69
+ } .navigation-bar-private__subtitle_16jqi {
70
+ font-size: 14px;
71
+ line-height: 20px;
72
+ font-weight: 400;
73
+ -webkit-line-clamp: 1;
74
+ display: -webkit-box;
75
+ -webkit-box-orient: vertical;
76
+ overflow: hidden;
77
+
78
+ color: var(--color-light-text-secondary);
79
+ word-break: break-all;
80
+ } .navigation-bar-private__addonsWrapper_16jqi {
81
+ display: flex;
82
+ } .navigation-bar-private__rightAddons_16jqi {
83
+ margin-left: auto;
84
+ } .navigation-bar-private__addon_16jqi {
85
+ min-width: 48px;
86
+ height: 48px;
87
+ display: flex;
88
+ justify-content: center;
89
+ align-items: center;
90
+ flex-shrink: 0;
91
+ pointer-events: all;
92
+ } .navigation-bar-private__bottomAddons_16jqi {
93
+ pointer-events: all;
94
+ } .navigation-bar-private__closer_16jqi {
95
+ margin-left: auto;
96
+ } .navigation-bar-private__left_16jqi {
97
+ text-align: left;
98
+ } .navigation-bar-private__center_16jqi {
99
+ text-align: center;
100
+ } .navigation-bar-private__trim_16jqi {
101
+ overflow: hidden
102
+ } .navigation-bar-private__trim_16jqi .navigation-bar-private__title_16jqi,
103
+ .navigation-bar-private__trim_16jqi .navigation-bar-private__children_16jqi {
104
+ -webkit-line-clamp: 2;
105
+ display: -webkit-box;
106
+ -webkit-box-orient: vertical;
107
+ overflow: hidden;
108
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Component";
2
+ export type { NavigationBarPrivateProps } from "./types";
@@ -0,0 +1 @@
1
+ export { NavigationBarPrivate } from './Component.js';
@@ -0,0 +1,2 @@
1
+ export * from "../components/closer/index";
2
+ export * from "../components/back-arrow-addon/index";
@@ -0,0 +1,2 @@
1
+ export { Closer } from '../components/closer/Component.js';
2
+ export { BackArrowAddon } from '../components/back-arrow-addon/Component.js';
@@ -0,0 +1,118 @@
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ import { ReactNode } from "react";
4
+ import { BackArrowAddonProps } from "./components/back-arrow-addon/index";
5
+ import { CloserProps } from "./components/closer/index";
6
+ type NavigationBarPrivateProps = {
7
+ /**
8
+ * Контент шапки
9
+ */
10
+ children?: ReactNode;
11
+ /**
12
+ * Заголовок шапки
13
+ */
14
+ title?: string;
15
+ /**
16
+ * Подзаголовок (доступен только в мобильной версии)
17
+ */
18
+ subtitle?: ReactNode;
19
+ /**
20
+ * Размер заголовка (compact доступен только в мобильной версии)
21
+ */
22
+ titleSize?: 'default' | 'compact';
23
+ /**
24
+ * Доп. класс для аддонов
25
+ */
26
+ addonClassName?: string;
27
+ /**
28
+ * Слот слева
29
+ */
30
+ leftAddons?: ReactNode;
31
+ /**
32
+ * Слот справа
33
+ */
34
+ rightAddons?: ReactNode;
35
+ /**
36
+ * Дополнительный класс для closer
37
+ */
38
+ closerClassName?: string;
39
+ /**
40
+ * Слот снизу
41
+ */
42
+ bottomAddons?: ReactNode;
43
+ /**
44
+ * Наличие компонента крестика
45
+ */
46
+ hasCloser?: boolean;
47
+ /**
48
+ * Наличие кнопки "Назад"
49
+ */
50
+ hasBackButton?: boolean;
51
+ /**
52
+ * Дополнительный класс для правого аддона
53
+ */
54
+ backButtonClassName?: string;
55
+ /**
56
+ * Дополнительные пропсы для кнопки "Назад"
57
+ */
58
+ backButtonProps?: Omit<BackArrowAddonProps, 'view' | 'textOpacity' | 'onClick'>;
59
+ /**
60
+ * Дополнительный класс
61
+ */
62
+ className?: string;
63
+ /**
64
+ * Дополнительный класс для контента
65
+ */
66
+ contentClassName?: string;
67
+ /**
68
+ * Дополнительный класс для нижнего аддона
69
+ */
70
+ bottomAddonsClassName?: string;
71
+ /**
72
+ * Выравнивание заголовка
73
+ */
74
+ align?: 'left' | 'center';
75
+ /**
76
+ * Обрезать ли заголовок
77
+ */
78
+ trim?: boolean;
79
+ /**
80
+ * Фиксирует шапку
81
+ */
82
+ sticky?: boolean;
83
+ /**
84
+ * Идентификатор для систем автоматизированного тестирования
85
+ */
86
+ dataTestId?: string;
87
+ /**
88
+ * Фоновое изображение
89
+ */
90
+ imageUrl?: string;
91
+ /**
92
+ * Иконка closer.
93
+ */
94
+ closerIcon?: React.ElementType;
95
+ /**
96
+ * Обработчик закрытия
97
+ */
98
+ onClose?: CloserProps['onClose'];
99
+ /**
100
+ * обработчик клика по кнопке "назад"
101
+ */
102
+ onBack?: () => void;
103
+ /**
104
+ * Вид шапки - мобильный или десктоп
105
+ */
106
+ view: 'desktop' | 'mobile';
107
+ /**
108
+ * Ссылка на родительскую ноду overflow: auto
109
+ */
110
+ scrollableParentRef?: React.RefObject<HTMLDivElement>;
111
+ };
112
+ type ContentParams = {
113
+ extraClassName?: string;
114
+ wrapperRef?: React.RefObject<HTMLDivElement>;
115
+ style?: React.CSSProperties;
116
+ hidden?: boolean;
117
+ };
118
+ export { NavigationBarPrivateProps, ContentParams };
@@ -0,0 +1 @@
1
+
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@alfalab/core-components-navigation-bar-private",
3
+ "version": "0.1.0",
4
+ "description": "Navigation bar private component",
5
+ "keywords": [],
6
+ "license": "MIT",
7
+ "main": "index.js",
8
+ "module": "./esm/index.js",
9
+ "publishConfig": {
10
+ "access": "public",
11
+ "directory": "dist"
12
+ },
13
+ "dependencies": {
14
+ "@alfalab/core-components-icon-button": "^6.5.4",
15
+ "@alfalab/core-components-button": "^11.4.1",
16
+ "@alfalab/core-components-typography": "^4.5.0",
17
+ "@alfalab/core-components-shared": "^0.9.1",
18
+ "@alfalab/hooks": "^1.13.0",
19
+ "@alfalab/icons-glyph": "^2.139.0",
20
+ "classnames": "^2.3.1",
21
+ "react-merge-refs": "^1.1.0",
22
+ "tslib": "^2.4.0"
23
+ },
24
+ "peerDependencies": {
25
+ "react": "^16.9.0 || ^17.0.1 || ^18.0.0"
26
+ }
27
+ }
@@ -0,0 +1,2 @@
1
+ export * from "../components/closer/index";
2
+ export * from "../components/back-arrow-addon/index";
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var components_closer_Component = require('../components/closer/Component.js');
6
+ var components_backArrowAddon_Component = require('../components/back-arrow-addon/Component.js');
7
+
8
+
9
+
10
+ exports.Closer = components_closer_Component.Closer;
11
+ exports.BackArrowAddon = components_backArrowAddon_Component.BackArrowAddon;
@@ -0,0 +1,3 @@
1
+ {
2
+ "module": "../esm/shared/index.js"
3
+ }
@@ -0,0 +1,284 @@
1
+ /* eslint-disable complexity */
2
+ import React, { forwardRef, useEffect, useRef, useState } from 'react';
3
+ import mergeRefs from 'react-merge-refs';
4
+ import cn from 'classnames';
5
+
6
+ import { getDataTestId } from '@alfalab/core-components-shared';
7
+ import { useLayoutEffect_SAFE_FOR_SSR } from '@alfalab/hooks';
8
+
9
+ import { BackArrowAddon } from './components/back-arrow-addon';
10
+ import { Closer } from './components/closer';
11
+ import type { ContentParams, NavigationBarPrivateProps } from './types';
12
+
13
+ import styles from './index.module.css';
14
+
15
+ const ADDONS_HEIGHT = 48;
16
+
17
+ export const NavigationBarPrivate = forwardRef<HTMLDivElement, NavigationBarPrivateProps>(
18
+ (
19
+ {
20
+ addonClassName,
21
+ className,
22
+ contentClassName,
23
+ closerClassName,
24
+ leftAddons,
25
+ rightAddons,
26
+ bottomAddons,
27
+ bottomAddonsClassName,
28
+ children,
29
+ align = 'left',
30
+ trim = true,
31
+ title,
32
+ titleSize = 'default',
33
+ subtitle,
34
+ hasCloser,
35
+ hasBackButton,
36
+ backButtonClassName,
37
+ backButtonProps,
38
+ dataTestId,
39
+ imageUrl,
40
+ closerIcon,
41
+ onClose,
42
+ view,
43
+ scrollableParentRef,
44
+ sticky,
45
+ onBack,
46
+ },
47
+ ref,
48
+ ) => {
49
+ const [scrollTop, setScrollTop] = useState(0);
50
+ const [titleMargin, setTitleMargin] = useState({ left: 0, right: 0 });
51
+ const bottomContentRef = useRef<HTMLDivElement>(null);
52
+ const headerRef = useRef<HTMLDivElement>(null);
53
+ const mainLinePaddingTopRef = useRef<string>('0px');
54
+ const leftAddonsRef = useRef<HTMLDivElement>(null);
55
+ const rightAddonsRef = useRef<HTMLDivElement>(null);
56
+
57
+ const compactTitle = view === 'mobile' && titleSize === 'compact';
58
+ const hasLeftPart = Boolean(leftAddons || hasBackButton);
59
+ const hasRightPart = Boolean(rightAddons || hasCloser);
60
+ const hasContent = Boolean(title || children);
61
+ const withAnimation = Boolean(view === 'mobile' && hasLeftPart && sticky && !compactTitle);
62
+ const showContentOnTop = hasContent && (compactTitle || !hasLeftPart);
63
+ const showContentOnBot = hasContent && !compactTitle && hasLeftPart;
64
+ const showStaticContentOnTop = !withAnimation && showContentOnTop;
65
+ const showStaticContentOnBot = !withAnimation && showContentOnBot;
66
+ const showAnimatedContentOnTop =
67
+ withAnimation && showContentOnBot && scrollTop > ADDONS_HEIGHT;
68
+ const showAnimatedContentOnBot = withAnimation && showContentOnBot;
69
+ const headerPaddingTop = mainLinePaddingTopRef.current;
70
+
71
+ useLayoutEffect_SAFE_FOR_SSR(() => {
72
+ if (align === 'center' && (showStaticContentOnTop || showAnimatedContentOnTop)) {
73
+ const leftAddonsWidth = leftAddonsRef.current?.offsetWidth || 0;
74
+ const rightAddonsWidth = rightAddonsRef.current?.offsetWidth || 0;
75
+
76
+ const marginSize = Math.abs(rightAddonsWidth - leftAddonsWidth);
77
+ const shouldAddLeftMargin = rightAddonsWidth - leftAddonsWidth > 0;
78
+
79
+ setTitleMargin((prev) => {
80
+ const newState = shouldAddLeftMargin
81
+ ? { left: marginSize, right: 0 }
82
+ : { left: 0, right: marginSize };
83
+
84
+ const isStateChanged =
85
+ prev.left !== newState.left || prev.right !== newState.right;
86
+
87
+ return isStateChanged ? newState : prev;
88
+ });
89
+ }
90
+ }, [
91
+ align,
92
+ showStaticContentOnTop,
93
+ showAnimatedContentOnTop,
94
+ leftAddons,
95
+ rightAddons,
96
+ hasBackButton,
97
+ hasCloser,
98
+ ]);
99
+
100
+ useEffect(() => {
101
+ const parent = scrollableParentRef?.current;
102
+
103
+ const handleScroll = (ev: Event) => {
104
+ const divElement = ev.target as HTMLDivElement;
105
+
106
+ setScrollTop(divElement.scrollTop);
107
+ };
108
+
109
+ if (withAnimation && headerRef.current) {
110
+ mainLinePaddingTopRef.current = getComputedStyle(headerRef.current).paddingTop;
111
+ }
112
+
113
+ if (withAnimation && parent) {
114
+ parent.addEventListener('scroll', handleScroll);
115
+ }
116
+
117
+ return () => parent?.removeEventListener('scroll', handleScroll);
118
+ }, [scrollableParentRef, withAnimation]);
119
+
120
+ const renderBackButton = () => {
121
+ let textOpacity = 1;
122
+
123
+ if (withAnimation) {
124
+ const height = hasContent ? ADDONS_HEIGHT : ADDONS_HEIGHT / 2;
125
+
126
+ textOpacity = Math.max(0, 1 - scrollTop / height);
127
+ } else if (compactTitle) {
128
+ textOpacity = 0;
129
+ }
130
+
131
+ return (
132
+ <div className={cn(styles.addon, backButtonClassName)}>
133
+ <BackArrowAddon
134
+ data-test-id={getDataTestId(dataTestId, 'back-button')}
135
+ {...backButtonProps}
136
+ textOpacity={textOpacity}
137
+ view={view}
138
+ onClick={onBack}
139
+ />
140
+ </div>
141
+ );
142
+ };
143
+
144
+ const renderContent = (args: ContentParams = {}) => {
145
+ const { extraClassName, wrapperRef, style, hidden } = args;
146
+
147
+ return (
148
+ <div
149
+ style={{ ...style, visibility: hidden ? 'hidden' : 'visible' }}
150
+ ref={wrapperRef}
151
+ className={cn(styles.content, extraClassName, contentClassName, styles[align], {
152
+ [styles.trim]: trim,
153
+ [styles.withCompactTitle]: view === 'mobile' && compactTitle && hasContent,
154
+ })}
155
+ aria-hidden={hidden}
156
+ >
157
+ {children && <div className={styles.children}>{children}</div>}
158
+ {title && (
159
+ <div
160
+ className={styles.title}
161
+ data-test-id={hidden ? undefined : getDataTestId(dataTestId, 'title')}
162
+ >
163
+ {title}
164
+ </div>
165
+ )}
166
+ {compactTitle && subtitle && <div className={styles.subtitle}>{subtitle}</div>}
167
+ </div>
168
+ );
169
+ };
170
+
171
+ const renderCloser = () => (
172
+ <div className={cn(styles.addon, styles.closer, closerClassName)}>
173
+ <Closer
174
+ view={view}
175
+ icon={closerIcon}
176
+ dataTestId={getDataTestId(dataTestId, 'closer')}
177
+ onClose={onClose}
178
+ />
179
+ </div>
180
+ );
181
+
182
+ return (
183
+ <div
184
+ ref={mergeRefs([ref, headerRef])}
185
+ className={cn(styles.header, className, { [styles.backgroundImage]: imageUrl })}
186
+ data-test-id={getDataTestId(dataTestId)}
187
+ style={{
188
+ ...(imageUrl && { backgroundImage: `url(${imageUrl})` }),
189
+ ...(withAnimation &&
190
+ bottomContentRef.current && {
191
+ top: -bottomContentRef.current.scrollHeight,
192
+ }),
193
+ }}
194
+ >
195
+ <div
196
+ className={cn(styles.mainLine, {
197
+ [styles.mainLineSticky]: withAnimation,
198
+ [styles.mainLineWithImageBg]: imageUrl,
199
+ })}
200
+ style={{
201
+ ...(withAnimation
202
+ ? {
203
+ marginTop: `-${headerPaddingTop}`,
204
+ paddingTop: headerPaddingTop,
205
+ }
206
+ : null),
207
+ }}
208
+ >
209
+ {hasLeftPart && (
210
+ <div className={styles.addonsWrapper} ref={leftAddonsRef}>
211
+ {hasBackButton && renderBackButton()}
212
+ {leftAddons && (
213
+ <div className={cn(styles.addon, addonClassName)}>{leftAddons}</div>
214
+ )}
215
+ </div>
216
+ )}
217
+
218
+ {showStaticContentOnTop &&
219
+ renderContent({
220
+ ...(align === 'center'
221
+ ? {
222
+ style: {
223
+ marginLeft: titleMargin.left,
224
+ marginRight: titleMargin.right,
225
+ },
226
+ }
227
+ : null),
228
+ })}
229
+
230
+ {showAnimatedContentOnTop &&
231
+ renderContent({
232
+ extraClassName: styles.withBothAddons,
233
+ style: {
234
+ opacity: Math.min(1, (scrollTop - ADDONS_HEIGHT) / ADDONS_HEIGHT),
235
+ ...(align === 'center'
236
+ ? {
237
+ marginLeft: titleMargin.left,
238
+ marginRight: titleMargin.right,
239
+ }
240
+ : null),
241
+ },
242
+ })}
243
+
244
+ {hasRightPart && (
245
+ <div
246
+ className={cn(styles.addonsWrapper, styles.rightAddons)}
247
+ ref={rightAddonsRef}
248
+ >
249
+ {rightAddons && (
250
+ <div className={cn(styles.addon, addonClassName)}>
251
+ {rightAddons}
252
+ </div>
253
+ )}
254
+
255
+ {hasCloser && renderCloser()}
256
+ </div>
257
+ )}
258
+ </div>
259
+
260
+ {showAnimatedContentOnBot &&
261
+ renderContent({
262
+ wrapperRef: bottomContentRef,
263
+ extraClassName: styles.underAddons,
264
+ style: { opacity: Math.max(0, 1 - scrollTop / ADDONS_HEIGHT) },
265
+ hidden: scrollTop / ADDONS_HEIGHT > 1,
266
+ })}
267
+
268
+ {showStaticContentOnBot &&
269
+ renderContent({
270
+ extraClassName: cn({
271
+ [styles.contentOnBotDesktop]: view === 'desktop',
272
+ [styles.contentOnBotMobile]: view === 'mobile',
273
+ }),
274
+ })}
275
+
276
+ {bottomAddons && (
277
+ <div className={cn(styles.bottomAddons, bottomAddonsClassName)}>
278
+ {bottomAddons}
279
+ </div>
280
+ )}
281
+ </div>
282
+ );
283
+ },
284
+ );