@hh.ru/magritte-ui-nav-bar 1.0.1

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 (79) hide show
  1. package/NavBar-CrD8CEWb.js +118 -0
  2. package/NavBar-CrD8CEWb.js.map +1 -0
  3. package/index.css +289 -0
  4. package/index.d.ts +9 -0
  5. package/index.js +35 -0
  6. package/index.js.map +1 -0
  7. package/index.mock.d.ts +17 -0
  8. package/index.mock.js +47 -0
  9. package/index.mock.js.map +1 -0
  10. package/internal/KeyedSubscriptions.d.ts +41 -0
  11. package/internal/KeyedSubscriptions.js +79 -0
  12. package/internal/KeyedSubscriptions.js.map +1 -0
  13. package/internal/MetricsProvider.d.ts +77 -0
  14. package/internal/MetricsProvider.js +275 -0
  15. package/internal/MetricsProvider.js.map +1 -0
  16. package/internal/MorphStore.d.ts +10 -0
  17. package/internal/MorphStore.js +36 -0
  18. package/internal/MorphStore.js.map +1 -0
  19. package/internal/PaneStore.d.ts +60 -0
  20. package/internal/PaneStore.js +102 -0
  21. package/internal/PaneStore.js.map +1 -0
  22. package/internal/ProgressiveBlur.d.ts +7 -0
  23. package/internal/ProgressiveBlur.js +43 -0
  24. package/internal/ProgressiveBlur.js.map +1 -0
  25. package/internal/useAnimationRanges.d.ts +38 -0
  26. package/internal/useAnimationRanges.js +52 -0
  27. package/internal/useAnimationRanges.js.map +1 -0
  28. package/internal/useBindScrollToAnimationProgress.d.ts +9 -0
  29. package/internal/useBindScrollToAnimationProgress.js +82 -0
  30. package/internal/useBindScrollToAnimationProgress.js.map +1 -0
  31. package/internal/useDivider.d.ts +4 -0
  32. package/internal/useDivider.js +38 -0
  33. package/internal/useDivider.js.map +1 -0
  34. package/internal/useNavBarMetrics.d.ts +9 -0
  35. package/internal/useNavBarMetrics.js +34 -0
  36. package/internal/useNavBarMetrics.js.map +1 -0
  37. package/internal/useResetFocus.d.ts +3 -0
  38. package/internal/useResetFocus.js +31 -0
  39. package/internal/useResetFocus.js.map +1 -0
  40. package/internal/useScrollAdapter.d.ts +15 -0
  41. package/internal/useScrollAdapter.js +116 -0
  42. package/internal/useScrollAdapter.js.map +1 -0
  43. package/internal/useSnapScroll.d.ts +6 -0
  44. package/internal/useSnapScroll.js +148 -0
  45. package/internal/useSnapScroll.js.map +1 -0
  46. package/internal/useSyncMotionValue.d.ts +2 -0
  47. package/internal/useSyncMotionValue.js +9 -0
  48. package/internal/useSyncMotionValue.js.map +1 -0
  49. package/internal/utils.d.ts +207 -0
  50. package/internal/utils.js +359 -0
  51. package/internal/utils.js.map +1 -0
  52. package/package.json +38 -0
  53. package/public/Actions.d.ts +26 -0
  54. package/public/Actions.js +47 -0
  55. package/public/Actions.js.map +1 -0
  56. package/public/EnvironmentFingerprintNode.d.ts +7 -0
  57. package/public/EnvironmentFingerprintNode.js +70 -0
  58. package/public/EnvironmentFingerprintNode.js.map +1 -0
  59. package/public/LayoutMorph.d.ts +32 -0
  60. package/public/LayoutMorph.js +132 -0
  61. package/public/LayoutMorph.js.map +1 -0
  62. package/public/LayoutStage.d.ts +7 -0
  63. package/public/LayoutStage.js +87 -0
  64. package/public/LayoutStage.js.map +1 -0
  65. package/public/Morph.d.ts +28 -0
  66. package/public/Morph.js +66 -0
  67. package/public/Morph.js.map +1 -0
  68. package/public/NavBar.d.ts +57 -0
  69. package/public/NavBar.js +21 -0
  70. package/public/NavBar.js.map +1 -0
  71. package/public/Pane.d.ts +22 -0
  72. package/public/Pane.js +79 -0
  73. package/public/Pane.js.map +1 -0
  74. package/public/Stage.d.ts +10 -0
  75. package/public/Stage.js +43 -0
  76. package/public/Stage.js.map +1 -0
  77. package/public/TitleContainer.d.ts +24 -0
  78. package/public/TitleContainer.js +34 -0
  79. package/public/TitleContainer.js.map +1 -0
package/public/Pane.js ADDED
@@ -0,0 +1,79 @@
1
+ import './../index.css';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { Children, isValidElement, cloneElement } from 'react';
4
+ import { useMotionValue, motion } from 'motion/react';
5
+ import { MorphStoreProvider } from '../internal/MorphStore.js';
6
+ import { usePaneStore, PaneContext } from '../internal/PaneStore.js';
7
+ import { useSyncMotionValue } from '../internal/useSyncMotionValue.js';
8
+ import { useInitOnce, useStoreSyncedTransform, lerp } from '../internal/utils.js';
9
+ import { EnvironmentFingerprintProvider } from './EnvironmentFingerprintNode.js';
10
+ import { LayoutStage } from './LayoutStage.js';
11
+ import { Stage } from './Stage.js';
12
+ import { s as styles } from '../NavBar-CrD8CEWb.js';
13
+ import '../internal/KeyedSubscriptions.js';
14
+ import 'motion';
15
+ import '../internal/MetricsProvider.js';
16
+ import 'classnames';
17
+ import '@hh.ru/magritte-common-use-when-font-loaded';
18
+ import '@hh.ru/magritte-ui-divider';
19
+ import '@hh.ru/magritte-ui-layer';
20
+ import '../internal/ProgressiveBlur.js';
21
+ import '../internal/useAnimationRanges.js';
22
+ import '../internal/useBindScrollToAnimationProgress.js';
23
+ import '../internal/useDivider.js';
24
+ import '../internal/useNavBarMetrics.js';
25
+ import '../internal/useResetFocus.js';
26
+ import '../internal/useScrollAdapter.js';
27
+ import '@hh.ru/magritte-internal-custom-scroll';
28
+ import '../internal/useSnapScroll.js';
29
+
30
+ const renderPaneChilds = (children, foldable) => {
31
+ const items = Children.toArray(children);
32
+ const stageContainers = items.filter((child) => isValidElement(child) && child.type === Stage);
33
+ const layoutStageContainers = items.filter((child) => isValidElement(child) && child.type === LayoutStage);
34
+ if ((stageContainers.length === 0 && layoutStageContainers.length === 0) || foldable) {
35
+ return jsx(Stage, { animationStage: "only", children: children });
36
+ }
37
+ if (layoutStageContainers.length > 0) {
38
+ return cloneElement(layoutStageContainers[0]);
39
+ }
40
+ stageContainers.length = Math.min(stageContainers.length, 2);
41
+ return stageContainers.map((child, index) => {
42
+ return cloneElement(child, {
43
+ ...child.props,
44
+ animationStage: stageContainers.length === 1 ? 'only' : ['start', 'end'][index],
45
+ });
46
+ });
47
+ };
48
+ const Pane = ({ children, nextPane, foldable, animationProgress }) => {
49
+ const paneStore = usePaneStore();
50
+ const y = useMotionValue(0);
51
+ const nextPaneY = useMotionValue(0);
52
+ const backgroundScale = useMotionValue(1);
53
+ const backgroundY = useMotionValue(0);
54
+ useSyncMotionValue(paneStore.get('motionValue'), animationProgress);
55
+ const contentHeight = useMotionValue('auto');
56
+ useInitOnce(() => paneStore.onChange('startHeight', () => contentHeight.set(paneStore.get('startHeight') ?? 'auto')));
57
+ paneStore.set({ foldable });
58
+ useStoreSyncedTransform(paneStore.get('motionValue'), paneStore, ['startHeight', 'endHeight'], () => ({
59
+ start: paneStore.get('startHeight') ?? 0,
60
+ end: paneStore.get('endHeight') ?? paneStore.get('startHeight') ?? 0,
61
+ }), (height, progress) => {
62
+ const heightDiff = height.end - height.start;
63
+ const shift = foldable ? progress * -height.start : 0;
64
+ y.set(shift);
65
+ nextPaneY.set(progress * heightDiff);
66
+ backgroundY.set(-shift);
67
+ backgroundScale.set(height.start === 0 ? 1 : lerp(height.start, foldable ? 0 : height.end, progress) / height.start);
68
+ });
69
+ return (jsxs(motion.div, { className: styles.pane, style: { y: foldable ? y : 0 }, children: [jsx(EnvironmentFingerprintProvider, { children: jsxs(motion.div, { className: styles.paneContent, style: { height: contentHeight }, children: [jsx(PaneContext.Provider, { value: paneStore, children: jsx(MorphStoreProvider, { children: renderPaneChilds(children, !!foldable) }) }), jsx(motion.div, { className: styles.paneBackground, "data-foldable": foldable, style: { scaleY: backgroundScale, y: backgroundY } })] }) }), !!nextPane && (jsx(motion.div, { className: styles.nextPane,
70
+ // если foldable уезжаем под контент, если нет то надо быть над контентом панели идущей перед
71
+ // т.к. если контент сверху становится меньше, то во время фейда следующая панель
72
+ // должна быть над ним, иначе исчезающий контент будет накладываться поверх панели пока
73
+ // не дойдем до конечной точки анимации, выглядит некрасиво
74
+ style: { y: nextPaneY, zIndex: nextPane.props.foldable ? 0 : 3 }, children: nextPane }))] }));
75
+ };
76
+ const ExternalPane = Pane;
77
+
78
+ export { ExternalPane, Pane };
79
+ //# sourceMappingURL=Pane.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Pane.js","sources":["../../src/public/Pane.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n isValidElement,\n type FC,\n type ReactNode,\n type JSXElementConstructor,\n type PropsWithChildren,\n type ReactElement,\n} from 'react';\nimport { useMotionValue, motion, type MotionValue } from 'motion/react';\n\nimport { MorphStoreProvider } from '@hh.ru/magritte-ui-nav-bar/internal/MorphStore';\nimport { PaneContext, usePaneStore } from '@hh.ru/magritte-ui-nav-bar/internal/PaneStore';\nimport { useSyncMotionValue } from '@hh.ru/magritte-ui-nav-bar/internal/useSyncMotionValue';\nimport { lerp, useInitOnce, useStoreSyncedTransform } from '@hh.ru/magritte-ui-nav-bar/internal/utils';\nimport { EnvironmentFingerprintProvider } from '@hh.ru/magritte-ui-nav-bar/public/EnvironmentFingerprintNode';\nimport { LayoutStage } from '@hh.ru/magritte-ui-nav-bar/public/LayoutStage';\nimport { Stage, type StageProps } from '@hh.ru/magritte-ui-nav-bar/public/Stage';\n\nimport styles from './nav-bar.less';\n\nexport type InternalPaneProps = PropsWithChildren<{\n foldable?: boolean;\n nextPane?: ReactElement<InternalPaneProps, JSXElementConstructor<InternalPaneProps>> | null;\n animationProgress?: MotionValue<number>;\n}>;\nexport type ExternalPaneProps = PropsWithChildren<{\n /**\n * Включает режим когда панель \"схлопывается\" под стоящую над ней панель.\n */\n foldable?: boolean;\n /**\n * Принимает MotionValue значение которого будет обновляться синхронно с анимацией панели.\n * Прогресс анимации представляется в виде числа 0..1\n * Предназначен для синхронизации внешних анимаций с анимацией панели.\n */\n animationProgress?: MotionValue<number>;\n}>;\n\nexport type PaneElement = ReactElement<ExternalPaneProps, JSXElementConstructor<ExternalPaneProps>>;\n\nconst renderPaneChilds = (children: ReactNode, foldable: boolean) => {\n const items = Children.toArray(children);\n const stageContainers = items.filter((child) => isValidElement(child) && child.type === Stage) as ReactElement<\n StageProps,\n JSXElementConstructor<StageProps>\n >[];\n const layoutStageContainers = items.filter(\n (child) => isValidElement(child) && child.type === LayoutStage\n ) as ReactElement<PropsWithChildren, JSXElementConstructor<PropsWithChildren>>[];\n\n if ((stageContainers.length === 0 && layoutStageContainers.length === 0) || foldable) {\n return <Stage animationStage=\"only\">{children}</Stage>;\n }\n\n if (layoutStageContainers.length > 0) {\n return cloneElement(layoutStageContainers[0]);\n }\n\n stageContainers.length = Math.min(stageContainers.length, 2);\n\n return stageContainers.map((child, index) => {\n return cloneElement(child, {\n ...child.props,\n animationStage: stageContainers.length === 1 ? 'only' : (['start', 'end'] as const)[index],\n });\n });\n};\n\nexport const Pane: FC<InternalPaneProps> = ({ children, nextPane, foldable, animationProgress }) => {\n const paneStore = usePaneStore();\n\n const y = useMotionValue(0);\n const nextPaneY = useMotionValue(0);\n const backgroundScale = useMotionValue(1);\n const backgroundY = useMotionValue(0);\n useSyncMotionValue(paneStore.get('motionValue'), animationProgress);\n\n const contentHeight = useMotionValue<number | 'auto'>('auto');\n useInitOnce(() =>\n paneStore.onChange('startHeight', () => contentHeight.set(paneStore.get('startHeight') ?? 'auto'))\n );\n\n paneStore.set({ foldable });\n\n useStoreSyncedTransform(\n paneStore.get('motionValue'),\n paneStore,\n ['startHeight', 'endHeight'],\n () => ({\n start: paneStore.get('startHeight') ?? 0,\n end: paneStore.get('endHeight') ?? paneStore.get('startHeight') ?? 0,\n }),\n (height, progress) => {\n const heightDiff = height.end - height.start;\n const shift = foldable ? progress * -height.start : 0;\n y.set(shift);\n nextPaneY.set(progress * heightDiff);\n backgroundY.set(-shift);\n backgroundScale.set(\n height.start === 0 ? 1 : lerp(height.start, foldable ? 0 : height.end, progress) / height.start\n );\n }\n );\n\n return (\n <motion.div className={styles.pane} style={{ y: foldable ? y : 0 }}>\n <EnvironmentFingerprintProvider>\n <motion.div className={styles.paneContent} style={{ height: contentHeight }}>\n <PaneContext.Provider value={paneStore}>\n <MorphStoreProvider>{renderPaneChilds(children, !!foldable)}</MorphStoreProvider>\n </PaneContext.Provider>\n <motion.div\n className={styles.paneBackground}\n data-foldable={foldable}\n style={{ scaleY: backgroundScale, y: backgroundY }}\n />\n </motion.div>\n </EnvironmentFingerprintProvider>\n\n {!!nextPane && (\n <motion.div\n className={styles.nextPane}\n // если foldable уезжаем под контент, если нет то надо быть над контентом панели идущей перед\n // т.к. если контент сверху становится меньше, то во время фейда следующая панель\n // должна быть над ним, иначе исчезающий контент будет накладываться поверх панели пока\n // не дойдем до конечной точки анимации, выглядит некрасиво\n style={{ y: nextPaneY, zIndex: nextPane.props.foldable ? 0 : 3 }}\n >\n {nextPane}\n </motion.div>\n )}\n </motion.div>\n );\n};\n\nexport const ExternalPane = Pane as FC<PropsWithChildren<ExternalPaneProps>>;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,gBAAgB,GAAG,CAAC,QAAmB,EAAE,QAAiB,KAAI;IAChE,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACzC,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAG1F,CAAC;IACJ,MAAM,qBAAqB,GAAG,KAAK,CAAC,MAAM,CACtC,CAAC,KAAK,KAAK,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,CACc,CAAC;AAEjF,IAAA,IAAI,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,IAAI,qBAAqB,CAAC,MAAM,KAAK,CAAC,KAAK,QAAQ,EAAE;QAClF,OAAOA,GAAA,CAAC,KAAK,EAAC,EAAA,cAAc,EAAC,MAAM,EAAA,QAAA,EAAE,QAAQ,EAAA,CAAS,CAAC;KAC1D;AAED,IAAA,IAAI,qBAAqB,CAAC,MAAM,GAAG,CAAC,EAAE;AAClC,QAAA,OAAO,YAAY,CAA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EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,EACvE,QAAA,EAAA,CAAAD,GAAA,CAAC,WAAW,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,SAAS,EAClC,QAAA,EAAAA,GAAA,CAAC,kBAAkB,EAAA,EAAA,QAAA,EAAE,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAsB,CAAA,EAAA,CAC9D,EACvBA,GAAC,CAAA,MAAM,CAAC,GAAG,EACP,EAAA,SAAS,EAAE,MAAM,CAAC,cAAc,EACjB,eAAA,EAAA,QAAQ,EACvB,KAAK,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC,EAAE,WAAW,EAAE,EAAA,CACpD,CACO,EAAA,CAAA,EAAA,CACgB,EAEhC,CAAC,CAAC,QAAQ,KACPA,GAAA,CAAC,MAAM,CAAC,GAAG,EAAA,EACP,SAAS,EAAE,MAAM,CAAC,QAAQ;;;;;AAK1B,gBAAA,KAAK,EAAE,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,GAAG,CAAC,EAAE,EAE/D,QAAA,EAAA,QAAQ,EACA,CAAA,CAChB,CACQ,EAAA,CAAA,EACf;AACN,EAAE;AAEK,MAAM,YAAY,GAAG;;;;"}
@@ -0,0 +1,10 @@
1
+ import { type FC, type PropsWithChildren } from 'react';
2
+ import { HTMLMotionProps } from 'motion/react';
3
+ type AnimationStage = 'start' | 'end' | 'only';
4
+ export declare const useAnimationStage: () => AnimationStage;
5
+ export type StageProps = PropsWithChildren<{
6
+ animationStage?: AnimationStage;
7
+ } & HTMLMotionProps<'div'>>;
8
+ export declare const Stage: FC<StageProps>;
9
+ export declare const ExternalStage: FC<PropsWithChildren>;
10
+ export {};
@@ -0,0 +1,43 @@
1
+ import './../index.css';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { createContext, useContext, useRef } from 'react';
4
+ import classNames from 'classnames';
5
+ import { useTransform, motion } from 'motion/react';
6
+ import { useMeasureAuto } from '../internal/MetricsProvider.js';
7
+ import { usePaneStore } from '../internal/PaneStore.js';
8
+ import { EnvironmentFingerprintNode } from './EnvironmentFingerprintNode.js';
9
+ import { s as styles } from '../NavBar-CrD8CEWb.js';
10
+ import '../internal/utils.js';
11
+ import 'motion';
12
+ import '../internal/KeyedSubscriptions.js';
13
+ import '@hh.ru/magritte-ui-divider';
14
+ import '@hh.ru/magritte-ui-layer';
15
+ import '../internal/ProgressiveBlur.js';
16
+ import '../internal/useAnimationRanges.js';
17
+ import '../internal/useBindScrollToAnimationProgress.js';
18
+ import '../internal/useDivider.js';
19
+ import '../internal/useNavBarMetrics.js';
20
+ import '../internal/useResetFocus.js';
21
+ import '../internal/useScrollAdapter.js';
22
+ import '@hh.ru/magritte-internal-custom-scroll';
23
+ import '../internal/useSnapScroll.js';
24
+ import '../internal/useSyncMotionValue.js';
25
+
26
+ const AnimationStageContext = createContext('only');
27
+ const useAnimationStage = () => useContext(AnimationStageContext);
28
+ const Stage = ({ children, animationStage = 'only', ...rest }) => {
29
+ const rootRef = useRef(null);
30
+ const paneStore = usePaneStore();
31
+ const isStartState = animationStage === 'start' || animationStage === 'only';
32
+ const isEndState = animationStage === 'end' || animationStage === 'only';
33
+ const isOnly = animationStage === 'only';
34
+ const motionValue = paneStore.get('motionValue');
35
+ const opacity = useTransform(motionValue, [0, 1], isStartState ? [1, 0] : [0, 1]);
36
+ const pointerEvents = useTransform(motionValue, (value) => (isStartState && value === 0) || (isEndState && value === 1) ? 'auto' : 'none');
37
+ useMeasureAuto(rootRef, (rect) => paneStore.set({ top: rect.top, [isStartState ? 'startHeight' : 'endHeight']: rect.height }), [animationStage, paneStore]);
38
+ return (jsx(motion.div, { ...rest, className: isStartState ? styles.startStateContainer : styles.endStateContainer, style: isOnly && !paneStore.get('foldable') ? {} : { opacity, pointerEvents }, children: jsx(EnvironmentFingerprintNode, { ref: rootRef, className: classNames(styles.contentContainer, styles.navBarStage), children: jsx(AnimationStageContext.Provider, { value: animationStage ?? 'only', children: children }) }) }));
39
+ };
40
+ const ExternalStage = Stage;
41
+
42
+ export { ExternalStage, Stage, useAnimationStage };
43
+ //# sourceMappingURL=Stage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Stage.js","sources":["../../src/public/Stage.tsx"],"sourcesContent":["import { createContext, useContext, useRef, type FC, type PropsWithChildren } from 'react';\nimport classNames from 'classnames';\nimport { useTransform, motion, HTMLMotionProps } from 'motion/react';\n\nimport { useMeasureAuto } from '@hh.ru/magritte-ui-nav-bar/internal/MetricsProvider';\nimport { usePaneStore } from '@hh.ru/magritte-ui-nav-bar/internal/PaneStore';\nimport { EnvironmentFingerprintNode } from '@hh.ru/magritte-ui-nav-bar/public/EnvironmentFingerprintNode';\n\nimport styles from './nav-bar.less';\n\ntype AnimationStage = 'start' | 'end' | 'only';\n\nconst AnimationStageContext = createContext<AnimationStage>('only');\n\nexport const useAnimationStage = (): AnimationStage => useContext(AnimationStageContext);\n\nexport type StageProps = PropsWithChildren<{ animationStage?: AnimationStage } & HTMLMotionProps<'div'>>;\n\nexport const Stage: FC<StageProps> = ({ children, animationStage = 'only', ...rest }) => {\n const rootRef = useRef<HTMLDivElement>(null);\n const paneStore = usePaneStore();\n const isStartState = animationStage === 'start' || animationStage === 'only';\n const isEndState = animationStage === 'end' || animationStage === 'only';\n const isOnly = animationStage === 'only';\n const motionValue = paneStore.get('motionValue');\n const opacity = useTransform(motionValue, [0, 1], isStartState ? [1, 0] : [0, 1]);\n const pointerEvents = useTransform(motionValue, (value) =>\n (isStartState && value === 0) || (isEndState && value === 1) ? 'auto' : 'none'\n );\n\n useMeasureAuto(\n rootRef,\n (rect) => paneStore.set({ top: rect.top, [isStartState ? 'startHeight' : 'endHeight']: rect.height }),\n [animationStage, paneStore]\n );\n\n return (\n <motion.div\n {...rest}\n className={isStartState ? styles.startStateContainer : styles.endStateContainer}\n style={isOnly && !paneStore.get('foldable') ? {} : { opacity, pointerEvents }}\n >\n <EnvironmentFingerprintNode\n ref={rootRef}\n className={classNames(styles.contentContainer, styles.navBarStage)}\n >\n <AnimationStageContext.Provider value={animationStage ?? 'only'}>\n {children}\n </AnimationStageContext.Provider>\n </EnvironmentFingerprintNode>\n </motion.div>\n );\n};\n\nexport const ExternalStage = Stage as FC<PropsWithChildren>;\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAM,qBAAqB,GAAG,aAAa,CAAiB,MAAM,CAAC,CAAC;AAEvD,MAAA,iBAAiB,GAAG,MAAsB,UAAU,CAAC,qBAAqB,EAAE;AAI5E,MAAA,KAAK,GAAmB,CAAC,EAAE,QAAQ,EAAE,cAAc,GAAG,MAAM,EAAE,GAAG,IAAI,EAAE,KAAI;AACpF,IAAA,MAAM,OAAO,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;AAC7C,IAAA,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,MAAM,YAAY,GAAG,cAAc,KAAK,OAAO,IAAI,cAAc,KAAK,MAAM,CAAC;IAC7E,MAAM,UAAU,GAAG,cAAc,KAAK,KAAK,IAAI,cAAc,KAAK,MAAM,CAAC;AACzE,IAAA,MAAM,MAAM,GAAG,cAAc,KAAK,MAAM,CAAC;IACzC,MAAM,WAAW,GAAG,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;AACjD,IAAA,MAAM,OAAO,GAAG,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAClF,IAAA,MAAM,aAAa,GAAG,YAAY,CAAC,WAAW,EAAE,CAAC,KAAK,KAClD,CAAC,YAAY,IAAI,KAAK,KAAK,CAAC,MAAM,UAAU,IAAI,KAAK,KAAK,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM,CACjF,CAAC;AAEF,IAAA,cAAc,CACV,OAAO,EACP,CAAC,IAAI,KAAK,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,YAAY,GAAG,aAAa,GAAG,WAAW,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EACrG,CAAC,cAAc,EAAE,SAAS,CAAC,CAC9B,CAAC;AAEF,IAAA,QACIA,GAAC,CAAA,MAAM,CAAC,GAAG,EAAA,EAAA,GACH,IAAI,EACR,SAAS,EAAE,YAAY,GAAG,MAAM,CAAC,mBAAmB,GAAG,MAAM,CAAC,iBAAiB,EAC/E,KAAK,EAAE,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,aAAa,EAAE,YAE7EA,GAAC,CAAA,0BAA0B,IACvB,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,WAAW,CAAC,EAElE,QAAA,EAAAA,GAAA,CAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,cAAc,IAAI,MAAM,EAC1D,QAAA,EAAA,QAAQ,GACoB,EACR,CAAA,EAAA,CACpB,EACf;AACN,EAAE;AAEK,MAAM,aAAa,GAAG;;;;"}
@@ -0,0 +1,24 @@
1
+ import { type FC, type ReactNode } from 'react';
2
+ export interface TitleContainerProps {
3
+ /**
4
+ * Контент левого слота
5
+ */
6
+ left?: ReactNode;
7
+ /**
8
+ * Контент слота для заголовка
9
+ */
10
+ title?: ReactNode;
11
+ /**
12
+ * Контент слота для подзаголовка
13
+ */
14
+ subtitle?: ReactNode;
15
+ /**
16
+ * Контент слота справа от заголовка
17
+ */
18
+ icon?: ReactNode;
19
+ /**
20
+ * Позволяет выровнять по горизонтали контент слотов для заголовка и подзаголовка
21
+ */
22
+ centered?: boolean;
23
+ }
24
+ export declare const TitleContainer: FC<TitleContainerProps>;
@@ -0,0 +1,34 @@
1
+ import './../index.css';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import classNames from 'classnames';
4
+ import { Morph } from './Morph.js';
5
+ import { s as styles } from '../NavBar-CrD8CEWb.js';
6
+ import 'react';
7
+ import 'motion/react';
8
+ import '../internal/MetricsProvider.js';
9
+ import '../internal/utils.js';
10
+ import '../internal/MorphStore.js';
11
+ import '../internal/KeyedSubscriptions.js';
12
+ import '../internal/PaneStore.js';
13
+ import 'motion';
14
+ import './EnvironmentFingerprintNode.js';
15
+ import './Stage.js';
16
+ import '@hh.ru/magritte-ui-divider';
17
+ import '@hh.ru/magritte-ui-layer';
18
+ import '../internal/ProgressiveBlur.js';
19
+ import '../internal/useAnimationRanges.js';
20
+ import '../internal/useBindScrollToAnimationProgress.js';
21
+ import '../internal/useDivider.js';
22
+ import '../internal/useNavBarMetrics.js';
23
+ import '../internal/useResetFocus.js';
24
+ import '../internal/useScrollAdapter.js';
25
+ import '@hh.ru/magritte-internal-custom-scroll';
26
+ import '../internal/useSnapScroll.js';
27
+ import '../internal/useSyncMotionValue.js';
28
+
29
+ const TitleContainer = ({ left, title, icon, subtitle, centered = false }) => {
30
+ return (jsxs("div", { className: styles.titleContainerWrapper, children: [!!left && (jsx("div", { className: styles.titleLeftSlot, children: jsx(Morph, { id: "title-component-left-slot", className: styles.titleMorphItem, children: left }) })), jsxs("div", { className: classNames(styles.titleMainPart, { [styles.centered]: centered }), children: [jsxs("div", { className: styles.titleContainer, children: [jsx("div", { className: styles.title, children: !!title && (jsx(Morph, { id: "title-component-title", className: styles.titleMorphItem, horizontalPositionAlign: "left", children: title })) }), jsx("div", { className: styles.titleInlineContainer, children: !!icon && (jsx(Morph, { id: "title-component-inline-slot", className: styles.titleMorphItem, children: icon })) })] }), jsx("div", { className: styles.subtitleContainer, children: !!subtitle && (jsx(Morph, { id: "title-component-subtitle", className: styles.titleMorphItem, horizontalPositionAlign: "left", children: subtitle })) })] })] }));
31
+ };
32
+
33
+ export { TitleContainer };
34
+ //# sourceMappingURL=TitleContainer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TitleContainer.js","sources":["../../src/public/TitleContainer.tsx"],"sourcesContent":["import { type FC, type ReactNode } from 'react';\nimport classNames from 'classnames';\n\nimport { Morph } from '@hh.ru/magritte-ui-nav-bar/public/Morph';\n\nimport styles from './nav-bar.less';\n\nexport interface TitleContainerProps {\n /**\n * Контент левого слота\n */\n left?: ReactNode;\n /**\n * Контент слота для заголовка\n */\n title?: ReactNode;\n /**\n * Контент слота для подзаголовка\n */\n subtitle?: ReactNode;\n /**\n * Контент слота справа от заголовка\n */\n icon?: ReactNode;\n /**\n * Позволяет выровнять по горизонтали контент слотов для заголовка и подзаголовка\n */\n centered?: boolean;\n}\n\nexport const TitleContainer: FC<TitleContainerProps> = ({ left, title, icon, subtitle, centered = false }) => {\n return (\n <div className={styles.titleContainerWrapper}>\n {!!left && (\n <div className={styles.titleLeftSlot}>\n <Morph id=\"title-component-left-slot\" className={styles.titleMorphItem}>\n {left}\n </Morph>\n </div>\n )}\n <div className={classNames(styles.titleMainPart, { [styles.centered]: centered })}>\n <div className={styles.titleContainer}>\n <div className={styles.title}>\n {!!title && (\n <Morph\n id=\"title-component-title\"\n className={styles.titleMorphItem}\n horizontalPositionAlign=\"left\"\n >\n {title}\n </Morph>\n )}\n </div>\n <div className={styles.titleInlineContainer}>\n {!!icon && (\n <Morph id=\"title-component-inline-slot\" className={styles.titleMorphItem}>\n {icon}\n </Morph>\n )}\n </div>\n </div>\n <div className={styles.subtitleContainer}>\n {!!subtitle && (\n <Morph\n id=\"title-component-subtitle\"\n className={styles.titleMorphItem}\n horizontalPositionAlign=\"left\"\n >\n {subtitle}\n </Morph>\n )}\n </div>\n </div>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8Ba,MAAA,cAAc,GAA4B,CAAC,EAAE,IAAI,EAAE,KA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