@astral/ui 4.51.0 → 4.52.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 (53) hide show
  1. package/components/DashboardContext/DashboardContext.d.ts +2 -0
  2. package/components/DashboardContext/DashboardContext.js +2 -0
  3. package/components/DashboardContext/DashboardContextProvider/DashboardContextProvider.d.ts +2 -2
  4. package/components/DashboardContext/DashboardContextProvider/DashboardContextProvider.js +4 -1
  5. package/components/DashboardLayout/DashboardLayout.d.ts +1 -1
  6. package/components/DashboardLayout/DashboardLayout.js +2 -2
  7. package/components/DashboardLayout/Header/Header.js +28 -3
  8. package/components/DashboardLayout/Header/constants.d.ts +5 -1
  9. package/components/DashboardLayout/Header/constants.js +5 -1
  10. package/components/DashboardLayout/Header/styles.d.ts +4 -3
  11. package/components/DashboardLayout/Header/styles.js +66 -24
  12. package/components/DashboardLayout/Header/useLogic/useLogic.d.ts +4 -1
  13. package/components/DashboardLayout/Header/useLogic/useLogic.js +16 -11
  14. package/components/DashboardLayout/types.d.ts +5 -0
  15. package/components/DashboardSidebar/DashboardSidebar.js +17 -2
  16. package/components/DashboardSidebar/constants.d.ts +1 -0
  17. package/components/DashboardSidebar/constants.js +1 -0
  18. package/components/DashboardSidebar/styles.js +1 -1
  19. package/components/DashboardSidebar/useLogic/useLogic.d.ts +2 -1
  20. package/components/DashboardSidebar/useLogic/useLogic.js +5 -6
  21. package/components/MenuOrganization/OrganizationButton/OrganizationButton.js +1 -1
  22. package/components/MenuOrganization/constants.d.ts +1 -0
  23. package/components/MenuOrganization/constants.js +1 -0
  24. package/components/Profile/Profile.js +1 -1
  25. package/components/Profile/constants.d.ts +3 -0
  26. package/components/Profile/constants.js +3 -0
  27. package/node/components/DashboardContext/DashboardContext.d.ts +2 -0
  28. package/node/components/DashboardContext/DashboardContext.js +2 -0
  29. package/node/components/DashboardContext/DashboardContextProvider/DashboardContextProvider.d.ts +2 -2
  30. package/node/components/DashboardContext/DashboardContextProvider/DashboardContextProvider.js +4 -1
  31. package/node/components/DashboardLayout/DashboardLayout.d.ts +1 -1
  32. package/node/components/DashboardLayout/DashboardLayout.js +2 -2
  33. package/node/components/DashboardLayout/Header/Header.js +27 -2
  34. package/node/components/DashboardLayout/Header/constants.d.ts +5 -1
  35. package/node/components/DashboardLayout/Header/constants.js +5 -1
  36. package/node/components/DashboardLayout/Header/styles.d.ts +4 -3
  37. package/node/components/DashboardLayout/Header/styles.js +74 -32
  38. package/node/components/DashboardLayout/Header/useLogic/useLogic.d.ts +4 -1
  39. package/node/components/DashboardLayout/Header/useLogic/useLogic.js +15 -10
  40. package/node/components/DashboardLayout/types.d.ts +5 -0
  41. package/node/components/DashboardSidebar/DashboardSidebar.js +17 -2
  42. package/node/components/DashboardSidebar/constants.d.ts +1 -0
  43. package/node/components/DashboardSidebar/constants.js +1 -0
  44. package/node/components/DashboardSidebar/styles.js +1 -1
  45. package/node/components/DashboardSidebar/useLogic/useLogic.d.ts +2 -1
  46. package/node/components/DashboardSidebar/useLogic/useLogic.js +4 -5
  47. package/node/components/MenuOrganization/OrganizationButton/OrganizationButton.js +1 -1
  48. package/node/components/MenuOrganization/constants.d.ts +1 -0
  49. package/node/components/MenuOrganization/constants.js +1 -0
  50. package/node/components/Profile/Profile.js +1 -1
  51. package/node/components/Profile/constants.d.ts +3 -0
  52. package/node/components/Profile/constants.js +3 -0
  53. package/package.json +1 -1
@@ -1,10 +1,12 @@
1
1
  import { type RefObject } from 'react';
2
2
  export type DashboardContextProps = {
3
3
  isFocusedMode: boolean;
4
+ mobileHeaderPriorityFeature: 'profile' | 'menuOrg';
4
5
  setAlertElement?: (element: HTMLElement | null) => void;
5
6
  alertHeight: number;
6
7
  isLoading: boolean;
7
8
  hasMenuOrganizationRef: RefObject<boolean | null>;
9
+ hasProfileRef: RefObject<boolean | null>;
8
10
  setFocusedMode: (isFocusedMode: boolean) => void;
9
11
  };
10
12
  export declare const DashboardContext: import("react").Context<DashboardContextProps>;
@@ -1,8 +1,10 @@
1
1
  import { createContext, createRef } from 'react';
2
2
  export const DashboardContext = createContext({
3
3
  isFocusedMode: false,
4
+ mobileHeaderPriorityFeature: 'menuOrg',
4
5
  alertHeight: 0,
5
6
  isLoading: false,
6
7
  hasMenuOrganizationRef: createRef(),
8
+ hasProfileRef: createRef(),
7
9
  setFocusedMode: () => undefined,
8
10
  });
@@ -1,8 +1,8 @@
1
1
  import { type ReactNode } from 'react';
2
2
  import { type DashboardContextProps } from '../DashboardContext';
3
- type Props = Pick<DashboardContextProps, 'isFocusedMode'> & {
3
+ type Props = Pick<DashboardContextProps, 'isFocusedMode' | 'mobileHeaderPriorityFeature'> & {
4
4
  children: ReactNode;
5
5
  isLoading: boolean;
6
6
  };
7
- export declare const DashboardContextProvider: ({ children, isFocusedMode, isLoading, }: Props) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const DashboardContextProvider: ({ children, isFocusedMode, isLoading, mobileHeaderPriorityFeature, }: Props) => import("react/jsx-runtime").JSX.Element;
8
8
  export {};
@@ -1,11 +1,12 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useRef, useState } from 'react';
3
3
  import { DashboardContext, } from '../DashboardContext';
4
- export const DashboardContextProvider = ({ children, isFocusedMode, isLoading, }) => {
4
+ export const DashboardContextProvider = ({ children, isFocusedMode, isLoading, mobileHeaderPriorityFeature, }) => {
5
5
  const [alertElement, setAlertElement] = useState(null);
6
6
  const [alertHeight, setAlertHeight] = useState(0);
7
7
  const [isFocusedModeInternal, setFocusedMode] = useState(isFocusedMode);
8
8
  const hasMenuOrganizationRef = useRef(false);
9
+ const hasProfileRef = useRef(false);
9
10
  useEffect(() => {
10
11
  if (isFocusedMode !== isFocusedModeInternal) {
11
12
  setFocusedMode(isFocusedMode);
@@ -27,9 +28,11 @@ export const DashboardContextProvider = ({ children, isFocusedMode, isLoading, }
27
28
  }, [alertElement]);
28
29
  return (_jsx(DashboardContext.Provider, { value: {
29
30
  isFocusedMode: isFocusedModeInternal,
31
+ mobileHeaderPriorityFeature,
30
32
  setAlertElement,
31
33
  alertHeight,
32
34
  isLoading,
35
+ hasProfileRef,
33
36
  hasMenuOrganizationRef,
34
37
  setFocusedMode,
35
38
  }, children: children }));
@@ -4,7 +4,7 @@ import { type DashboardLayoutProps } from './types';
4
4
  * Общий Layout приложения
5
5
  */
6
6
  export declare const DashboardLayout: {
7
- ({ children, isFocusedMode, isLoading, }: DashboardLayoutProps): import("react/jsx-runtime").JSX.Element;
7
+ ({ children, isFocusedMode, isLoading, mobileHeaderPriorityFeature, }: DashboardLayoutProps): import("react/jsx-runtime").JSX.Element;
8
8
  Header: import("react").ForwardRefExoticComponent<import("./Header").HeaderProps & import("react").RefAttributes<HTMLDivElement>>;
9
9
  Sidebar: import("react").ForwardRefExoticComponent<import("../DashboardSidebar").DashboardSidebarProps & import("react").RefAttributes<HTMLBaseElement>>;
10
10
  Main: import("react").ForwardRefExoticComponent<import("./Main").MainProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -7,8 +7,8 @@ import { Main } from './Main';
7
7
  /**
8
8
  * Общий Layout приложения
9
9
  */
10
- export const DashboardLayout = ({ children, isFocusedMode = false, isLoading = false, }) => {
11
- return (_jsx(DashboardContextProvider, { isFocusedMode: isFocusedMode, isLoading: isLoading, children: _jsx(DashboardWrapper, { children: children }) }));
10
+ export const DashboardLayout = ({ children, isFocusedMode = false, isLoading = false, mobileHeaderPriorityFeature = 'menuOrg', }) => {
11
+ return (_jsx(DashboardContextProvider, { isFocusedMode: isFocusedMode, isLoading: isLoading, mobileHeaderPriorityFeature: mobileHeaderPriorityFeature, children: _jsx(DashboardWrapper, { children: children }) }));
12
12
  };
13
13
  DashboardLayout.Header = Header;
14
14
  DashboardLayout.Sidebar = DashboardSidebar;
@@ -6,15 +6,40 @@ import { QuitOutlineMd } from '../../../icons/QuitOutlineMd';
6
6
  import { Button } from '../../Button';
7
7
  import { Product } from '../../Product';
8
8
  import { Profile } from '../../Profile';
9
+ import { cva } from '../../utils/cva';
9
10
  import { getInertProps } from '../../utils/getInertProps';
10
11
  import { dashboardLayoutHeaderClassnames } from './constants';
11
- import { ExitButton, HeaderContent, HeaderContentSection, HeaderRoot, HeaderSection, MenuOrganizationWrapper, MobileSidebarTogglerWrapper, ProductSwitcherWrapper, ProfileWrapper, } from './styles';
12
+ import { ExitButton, HeaderContent, HeaderContentSection, HeaderRoot, HeaderSection, MobileSidebarTogglerWrapper, PriorityFeatureWrapper, ProductSwitcherWrapper, ProfileWrapper, } from './styles';
12
13
  import { useLogic } from './useLogic';
14
+ const headerPriorityFeature = cva('', {
15
+ variants: {
16
+ feature: {
17
+ menuOrg: dashboardLayoutHeaderClassnames.priorityFeatureMenuOrg,
18
+ profile: dashboardLayoutHeaderClassnames.priorityFeatureProfile,
19
+ },
20
+ isPinned: {
21
+ true: dashboardLayoutHeaderClassnames.mobileSidebarPriorityFeatureVisible,
22
+ },
23
+ featureInSidebar: {
24
+ true: dashboardLayoutHeaderClassnames.featureInSidebar,
25
+ },
26
+ },
27
+ });
13
28
  /**
14
29
  * Основной header приложения
15
30
  */
16
31
  export const Header = forwardRef((props, ref) => {
17
32
  const { productSwitcher: ProductSwitcher, product, profile, menuOrganization, children, } = props;
18
- const { isShowExitButton, isShowProfile, isFocusedMode, isMobile, collapsedIn, onToggleSidebar, isLoading, alertHeight, menuOrganizationClassnames, } = useLogic(props);
19
- return (_jsx(HeaderRoot, { ref: ref, "$isFocusedMode": isFocusedMode, ...getInertProps(!isMobile && isFocusedMode), className: dashboardLayoutHeaderClassnames.root, children: _jsxs(HeaderContent, { children: [_jsx(MobileSidebarTogglerWrapper, { className: dashboardLayoutHeaderClassnames.mobileSidebarButton, children: _jsx(Button, { startIcon: collapsedIn ? _jsx(CrossOutlineMd, {}) : _jsx(MenuOnOutlineMd, {}), variant: "text", onClick: () => onToggleSidebar(), title: "\u041F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C \u0431\u043E\u043A\u043E\u0432\u043E\u0435 \u043C\u0435\u043D\u044E" }) }), _jsxs(HeaderSection, { children: [ProductSwitcher && (_jsx(ProductSwitcherWrapper, { children: _jsx(ProductSwitcher, {}) })), _jsx(Product, { ...product })] }), _jsxs(HeaderContentSection, { children: [children, menuOrganization && (_jsx(MenuOrganizationWrapper, { className: menuOrganizationClassnames, "$alertHeight": alertHeight, children: menuOrganization() })), profile && (_jsx(ProfileWrapper, { "$isShow": isShowProfile, children: _jsx(Profile, { isLoading: isLoading, ...profile }) })), _jsx(ExitButton, { "$isShow": isShowExitButton, onClick: profile?.exitButton?.onClick, title: "\u0412\u044B\u0445\u043E\u0434", variant: "text", children: _jsx(QuitOutlineMd, {}) })] })] }) }));
33
+ const { isShowExitButton, isShowProfile, isFocusedMode, isMobile, collapsedIn, onToggleSidebar, isLoading, mobileHeaderPriorityFeature, headerStyle, isPinned, } = useLogic(props);
34
+ return (_jsx(HeaderRoot, { ref: ref, "$isFocusedMode": isFocusedMode, ...getInertProps(!isMobile && isFocusedMode), className: dashboardLayoutHeaderClassnames.root, style: headerStyle, children: _jsxs(HeaderContent, { children: [_jsx(MobileSidebarTogglerWrapper, { className: dashboardLayoutHeaderClassnames.mobileSidebarButton, children: _jsx(Button, { startIcon: collapsedIn ? _jsx(CrossOutlineMd, {}) : _jsx(MenuOnOutlineMd, {}), variant: "text", onClick: () => onToggleSidebar(), title: "\u041F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C \u0431\u043E\u043A\u043E\u0432\u043E\u0435 \u043C\u0435\u043D\u044E" }) }), _jsxs(HeaderSection, { children: [ProductSwitcher && (_jsx(ProductSwitcherWrapper, { children: _jsx(ProductSwitcher, {}) })), _jsx(Product, { ...product })] }), _jsxs(HeaderContentSection, { className: headerPriorityFeature({
35
+ feature: mobileHeaderPriorityFeature,
36
+ }), children: [children, menuOrganization && (_jsx(PriorityFeatureWrapper, { className: headerPriorityFeature({
37
+ feature: mobileHeaderPriorityFeature,
38
+ isPinned,
39
+ featureInSidebar: mobileHeaderPriorityFeature === 'profile',
40
+ }), children: menuOrganization() })), profile && (_jsx(PriorityFeatureWrapper, { className: headerPriorityFeature({
41
+ feature: mobileHeaderPriorityFeature,
42
+ isPinned,
43
+ featureInSidebar: mobileHeaderPriorityFeature === 'menuOrg',
44
+ }), children: _jsx(ProfileWrapper, { className: dashboardLayoutHeaderClassnames.profile, "$isShow": isShowProfile, children: _jsx(Profile, { isLoading: isLoading, ...profile }) }) })), _jsx(ExitButton, { "$isShow": isShowExitButton, onClick: profile?.exitButton?.onClick, title: "\u0412\u044B\u0445\u043E\u0434", variant: "text", children: _jsx(QuitOutlineMd, {}) })] })] }) }));
20
45
  });
@@ -1,5 +1,9 @@
1
1
  export declare const dashboardLayoutHeaderClassnames: {
2
2
  root: string;
3
3
  mobileSidebarButton: string;
4
- mobileMenuOrganizationVisible: string;
4
+ priorityFeatureMenuOrg: string;
5
+ priorityFeatureProfile: string;
6
+ mobileSidebarPriorityFeatureVisible: string;
7
+ featureInSidebar: string;
8
+ profile: string;
5
9
  };
@@ -2,5 +2,9 @@ import { createUIKitClassname } from '../../utils/createUIKitClassname';
2
2
  export const dashboardLayoutHeaderClassnames = {
3
3
  root: createUIKitClassname('dashboard-layout-header'),
4
4
  mobileSidebarButton: createUIKitClassname('dashboard-layout-header__sidebar-button_mobile'),
5
- mobileMenuOrganizationVisible: createUIKitClassname('dashboard-layout-header__menu-organization_visible'),
5
+ priorityFeatureMenuOrg: createUIKitClassname('dashboard-layout-header__priority-feature_menu-org'),
6
+ priorityFeatureProfile: createUIKitClassname('dashboard-layout-header__priority-feature_profile'),
7
+ mobileSidebarPriorityFeatureVisible: createUIKitClassname('dashboard-layout-header__sidebar-priority-feature_visible'),
8
+ featureInSidebar: createUIKitClassname('dashboard-layout-header__feature-in-sidebar'),
9
+ profile: createUIKitClassname('dashboard-layout-header__profile'),
6
10
  };
@@ -44,9 +44,10 @@ export declare const HeaderContent: import("../../styled").StyledComponent<{
44
44
  theme?: import("@emotion/react").Theme | undefined;
45
45
  as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
46
46
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
47
- export declare const MenuOrganizationWrapper: import("../../styled").StyledComponent<{
47
+ /**
48
+ * Обертка для элементов которые должны быть в мобильном хедере или помещены в sidebar.
49
+ */
50
+ export declare const PriorityFeatureWrapper: import("../../styled").StyledComponent<{
48
51
  theme?: import("@emotion/react").Theme | undefined;
49
52
  as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
50
- } & {
51
- $alertHeight?: number | undefined;
52
53
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -3,6 +3,7 @@ import { dashboardSidebarClassnames } from '../../DashboardSidebar/constants';
3
3
  import { IconButton } from '../../IconButton';
4
4
  import { menuOrganizationClassnames } from '../../MenuOrganization/constants';
5
5
  import { MOBILE_BUTTON_HEIGHT } from '../../MenuOrganization/OrganizationButton/constants';
6
+ import { profileClassnames } from '../../Profile/constants';
6
7
  import { styled } from '../../styled';
7
8
  import { dashboardLayoutClassnames, HEADER_HEIGHT_DESKTOP, HEADER_HEIGHT_LAPTOP, HEADER_HEIGHT_MOBILE, } from '../constants';
8
9
  import { dashboardLayoutHeaderClassnames } from './constants';
@@ -77,6 +78,15 @@ export const HeaderContentSection = styled(HeaderSection) `
77
78
 
78
79
  ${({ theme }) => theme.breakpoints.down('sm')} {
79
80
  gap: ${({ theme }) => theme.spacing(2)};
81
+
82
+ &.${dashboardLayoutHeaderClassnames.priorityFeatureMenuOrg} {
83
+ & .${menuOrganizationClassnames.organizationData} {
84
+ display: none;
85
+ }
86
+ & .${menuOrganizationClassnames.button} {
87
+ border-radius: ${({ theme }) => theme.shape.medium};
88
+ }
89
+ }
80
90
  }
81
91
  `;
82
92
  export const ProductSwitcherWrapper = styled.div `
@@ -111,45 +121,77 @@ export const HeaderContent = styled.div `
111
121
  padding: 0;
112
122
  }
113
123
  `;
114
- export const MenuOrganizationWrapper = styled.div `
124
+ /**
125
+ * Обертка для элементов которые должны быть в мобильном хедере или помещены в sidebar.
126
+ */
127
+ export const PriorityFeatureWrapper = styled.div `
115
128
  ${({ theme }) => theme.breakpoints.down('sm')} {
116
- position: absolute;
117
- z-index: ${({ theme }) => theme.zIndex.appBar - 1};
118
- top: ${({ $alertHeight }) => `calc(${$alertHeight}px + ${HEADER_HEIGHT_MOBILE}) `};
119
- left: 0;
120
-
121
- /* Необходимо для анимации компонента вместе с sidebar */
122
- transform: translateX(-100vw);
123
129
 
124
- display: flex;
125
- flex-direction: column;
130
+ &.${dashboardLayoutHeaderClassnames.featureInSidebar} {
131
+ position: absolute;
132
+ z-index: ${({ theme }) => theme.zIndex.appBar - 1};
133
+ top: calc(var(--alert-height, 0px) + ${HEADER_HEIGHT_MOBILE});
134
+ left: 0;
135
+
136
+ /* Необходимо для анимации компонента вместе с sidebar */
137
+ transform: translateX(-100vw);
126
138
 
127
- width: 100vw;
139
+ display: flex;
140
+ flex-direction: column;
128
141
 
129
- background-color: ${({ theme }) => theme.palette.background.default};
142
+ width: 100vw;
130
143
 
131
- transition: ${({ theme }) => {
144
+ background-color: ${({ theme }) => theme.palette.background.default};
145
+
146
+ transition: ${({ theme }) => {
132
147
  return theme.transitions.create(['transform'], {
133
148
  duration: theme.transitions.duration.standard,
134
149
  });
135
150
  }};
136
151
 
137
- &.${dashboardLayoutHeaderClassnames.mobileMenuOrganizationVisible} {
138
- transform: translateX(0);
139
- }
140
-
141
- & .${menuOrganizationClassnames.button} {
142
- height: ${MOBILE_BUTTON_HEIGHT};
143
- padding: ${({ theme }) => theme.spacing(3, 4)};
152
+ &.${dashboardLayoutHeaderClassnames.mobileSidebarPriorityFeatureVisible} {
153
+ transform: translateX(0);
154
+ }
144
155
 
145
- border-bottom: 1px solid ${({ theme }) => theme.palette.grey[300]};
156
+ & .${menuOrganizationClassnames.button}, & .${profileClassnames.button} {
157
+ height: ${MOBILE_BUTTON_HEIGHT};
158
+ padding: ${({ theme }) => theme.spacing(3, 4)};
146
159
 
147
- &:hover {
148
160
  border-bottom: 1px solid ${({ theme }) => theme.palette.grey[300]};
161
+
162
+ &:hover {
163
+ border-bottom: 1px solid ${({ theme }) => theme.palette.grey[300]};
164
+ }
165
+
166
+ &:active {
167
+ border-bottom: 1px solid ${({ theme }) => theme.palette.grey[300]};
168
+ }
149
169
  }
150
170
 
151
- &:active {
152
- border-bottom: 1px solid ${({ theme }) => theme.palette.grey[300]};
171
+ &.${dashboardLayoutHeaderClassnames.priorityFeatureMenuOrg} {
172
+ & .${dashboardLayoutHeaderClassnames.profile} {
173
+ display: block;
174
+ }
175
+
176
+
177
+ & .${profileClassnames.button} {
178
+ width: 100%;
179
+ max-width: unset;
180
+
181
+ border-radius: 0;
182
+ }
183
+
184
+ & .${profileClassnames.avatar} {
185
+ display: none;
186
+ }
187
+
188
+ & .${profileClassnames.user} {
189
+ display: flex;
190
+ align-items: center;
191
+ justify-content: space-between;
192
+
193
+ width: 100%;
194
+ }
153
195
  }
154
196
  }
155
197
  }
@@ -1,12 +1,15 @@
1
+ import { type CSSProperties } from 'react';
1
2
  import { type HeaderProps } from '../types';
2
3
  export declare const useLogic: ({ profile, menuOrganization }: HeaderProps) => {
3
4
  isShowExitButton: boolean;
4
5
  isShowProfile: boolean;
5
6
  isMobile: boolean;
6
7
  isFocusedMode: boolean;
8
+ mobileHeaderPriorityFeature: "profile" | "menuOrg";
7
9
  isLoading: boolean;
8
10
  collapsedIn: boolean;
9
11
  onToggleSidebar: (newValue?: boolean | undefined) => void;
10
12
  alertHeight: number;
11
- menuOrganizationClassnames: string;
13
+ isPinned: boolean;
14
+ headerStyle: CSSProperties;
12
15
  };
@@ -1,31 +1,36 @@
1
- import { useContext, useEffect, useMemo } from 'react';
1
+ import { useContext, useEffect } from 'react';
2
2
  import { DashboardContext } from '../../../DashboardContext';
3
3
  import { DashboardSidebarContext } from '../../../DashboardSidebarProvider';
4
4
  import { useViewportType } from '../../../useViewportType';
5
- import { classNames } from '../../../utils/classNames';
6
- import { dashboardLayoutHeaderClassnames } from '../constants';
7
5
  export const useLogic = ({ profile, menuOrganization }) => {
8
- const { isFocusedMode, isLoading, hasMenuOrganizationRef, alertHeight } = useContext(DashboardContext);
6
+ const { isFocusedMode, isLoading, hasMenuOrganizationRef, hasProfileRef, alertHeight, mobileHeaderPriorityFeature, } = useContext(DashboardContext);
9
7
  const { collapsedIn, onToggleSidebar, isPinned } = useContext(DashboardSidebarContext);
10
8
  useEffect(() => {
11
9
  hasMenuOrganizationRef.current = Boolean(menuOrganization);
12
- }, [menuOrganization]);
10
+ hasProfileRef.current = Boolean(profile);
11
+ }, [menuOrganization, profile]);
13
12
  const { isMobile } = useViewportType();
14
13
  const hasMenu = Boolean(profile?.menu || profile?.menuList);
15
- const isShowProfile = (Boolean(profile) && !isMobile) || (hasMenu && isMobile);
16
- const isShowExitButton = isMobile && !hasMenu && Boolean(profile?.exitButton);
17
- const menuOrganizationClassnames = useMemo(() => classNames({
18
- [dashboardLayoutHeaderClassnames.mobileMenuOrganizationVisible]: isPinned,
19
- }), [isPinned]);
14
+ const isShowProfile = (Boolean(profile) && !isMobile) ||
15
+ (hasMenu && isMobile && mobileHeaderPriorityFeature === 'profile');
16
+ const isShowExitButton = isMobile &&
17
+ !hasMenu &&
18
+ Boolean(profile?.exitButton) &&
19
+ mobileHeaderPriorityFeature === 'profile';
20
+ const headerStyle = {
21
+ '--alert-height': `${alertHeight}px`,
22
+ };
20
23
  return {
21
24
  isShowExitButton,
22
25
  isShowProfile,
23
26
  isMobile,
24
27
  isFocusedMode,
28
+ mobileHeaderPriorityFeature,
25
29
  isLoading,
26
30
  collapsedIn,
27
31
  onToggleSidebar,
28
32
  alertHeight,
29
- menuOrganizationClassnames,
33
+ isPinned,
34
+ headerStyle,
30
35
  };
31
36
  };
@@ -10,4 +10,9 @@ export type DashboardLayoutProps = {
10
10
  * Если true, отображается состояние загрузки
11
11
  */
12
12
  isLoading?: boolean;
13
+ /**
14
+ * Элемент, отображаемый в мобильном хедере.
15
+ * Второстепенный будет помещен в sidebar.
16
+ */
17
+ mobileHeaderPriorityFeature?: 'profile' | 'menuOrg';
13
18
  };
@@ -3,17 +3,32 @@ import { forwardRef } from 'react';
3
3
  import { DashboardSidebarSkeleton } from '../DashboardSidebarSkeleton';
4
4
  import { NavMenu } from '../NavMenu';
5
5
  import { PinButton } from '../PinButton';
6
+ import { cva } from '../utils/cva';
6
7
  import { getInertProps } from '../utils/getInertProps';
8
+ import { dashboardSidebarClassnames } from './constants';
7
9
  import { SidebarNav } from './SidebarNav';
8
10
  import { Footer, SidebarContent, SidebarHeader, SidebarRoot, StyledPaper, Wrapper, } from './styles';
9
11
  import { useLogic } from './useLogic';
12
+ const sidebar = cva('', {
13
+ variants: {
14
+ hasProfile: {
15
+ true: dashboardSidebarClassnames.hasProfile,
16
+ },
17
+ hasMenuOrganization: {
18
+ true: dashboardSidebarClassnames.hasMenuOrganization,
19
+ },
20
+ },
21
+ });
10
22
  /**
11
23
  * Основной sidebar приложения
12
24
  */
13
25
  export const DashboardSidebar = forwardRef((props, ref) => {
14
- const { isPinned, isMobile, collapsedIn, onTogglePin, onMouseEnter, onMouseLeave, alertHeight, classnames, wrapperClassnames, menu, header, isLoading, } = useLogic(props);
26
+ const { isPinned, isMobile, collapsedIn, onTogglePin, onMouseEnter, onMouseLeave, alertHeight, classnames, menu, header, isLoading, hasMenuOrganization, hasProfile, } = useLogic(props);
15
27
  if (isLoading) {
16
28
  return _jsx(DashboardSidebarSkeleton, {});
17
29
  }
18
- return (_jsx(Wrapper, { "$isPinned": isPinned, "$alertHeight": alertHeight, className: wrapperClassnames, children: _jsx(SidebarRoot, { ref: ref, "$isPinned": isPinned, "$collapsedIn": collapsedIn, className: classnames, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, ...getInertProps(isMobile && !isPinned), children: _jsxs(StyledPaper, { variant: "outlined", children: [_jsxs(SidebarContent, { "$collapsedIn": collapsedIn, "$isPinned": isPinned, "$hasHeader": Boolean(header), children: [header && _jsx(SidebarHeader, { children: header }), _jsx(SidebarNav, { menu: _jsx(NavMenu, { collapsedIn: collapsedIn, items: menu.items }) })] }), _jsx(Footer, { children: _jsx(PinButton, { isPinned: isPinned, collapsedIn: collapsedIn, onClick: onTogglePin }) })] }) }) }));
30
+ return (_jsx(Wrapper, { "$isPinned": isPinned, "$alertHeight": alertHeight, className: sidebar({
31
+ hasProfile,
32
+ hasMenuOrganization,
33
+ }), children: _jsx(SidebarRoot, { ref: ref, "$isPinned": isPinned, "$collapsedIn": collapsedIn, className: classnames, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, ...getInertProps(isMobile && !isPinned), children: _jsxs(StyledPaper, { variant: "outlined", children: [_jsxs(SidebarContent, { "$collapsedIn": collapsedIn, "$isPinned": isPinned, "$hasHeader": Boolean(header), children: [header && _jsx(SidebarHeader, { children: header }), _jsx(SidebarNav, { menu: _jsx(NavMenu, { collapsedIn: collapsedIn, items: menu.items }) })] }), _jsx(Footer, { children: _jsx(PinButton, { isPinned: isPinned, collapsedIn: collapsedIn, onClick: onTogglePin }) })] }) }) }));
19
34
  });
@@ -1,5 +1,6 @@
1
1
  export declare const dashboardSidebarClassnames: {
2
2
  root: string;
3
+ hasProfile: string;
3
4
  hasMenuOrganization: string;
4
5
  };
5
6
  export declare const LABEL_WIDTH: {
@@ -1,6 +1,7 @@
1
1
  import { createUIKitClassname } from '../utils/createUIKitClassname';
2
2
  export const dashboardSidebarClassnames = {
3
3
  root: createUIKitClassname('dashboard-layout-sidebar'),
4
+ hasProfile: createUIKitClassname('dashboard-layout-sidebar_has-profile'),
4
5
  hasMenuOrganization: createUIKitClassname('dashboard-layout-sidebar_has-menu-organization'),
5
6
  };
6
7
  export const LABEL_WIDTH = {
@@ -35,7 +35,7 @@ export const Wrapper = styled('div', {
35
35
  });
36
36
  }};
37
37
 
38
- &.${dashboardSidebarClassnames.hasMenuOrganization} {
38
+ &.${dashboardSidebarClassnames.hasMenuOrganization}, &.${dashboardSidebarClassnames.hasProfile} {
39
39
  top: ${({ $alertHeight }) => `calc(${$alertHeight}px + ${HEADER_HEIGHT_MOBILE} + ${MOBILE_BUTTON_HEIGHT}) `};
40
40
  }
41
41
  }
@@ -28,5 +28,6 @@ export declare const useLogic: (props: DashboardSidebarProps) => {
28
28
  header: import("react").ReactNode;
29
29
  isLoading: boolean;
30
30
  classnames: string;
31
- wrapperClassnames: string;
31
+ hasMenuOrganization: boolean | null;
32
+ hasProfile: boolean | null;
32
33
  };
@@ -1,4 +1,4 @@
1
- import { useContext, useEffect, useMemo, useRef } from 'react';
1
+ import { useContext, useEffect, useRef } from 'react';
2
2
  import { DashboardContext } from '../../DashboardContext';
3
3
  import { dashboardLayoutHeaderClassnames } from '../../DashboardLayout/Header';
4
4
  import { dashboardLayoutMainClassnames } from '../../DashboardLayout/Main';
@@ -10,7 +10,7 @@ import { dashboardSidebarClassnames } from '../constants';
10
10
  export const useLogic = (props) => {
11
11
  const { className, menu, header, isLoading } = props;
12
12
  const { onToggleSidebar, isPinned, onTogglePin, collapsedIn, setIsPopupOpen, } = useContext(DashboardSidebarContext);
13
- const { alertHeight, isLoading: isDashboardLoading, hasMenuOrganizationRef, } = useContext(DashboardContext);
13
+ const { alertHeight, isLoading: isDashboardLoading, hasMenuOrganizationRef, hasProfileRef, mobileHeaderPriorityFeature, } = useContext(DashboardContext);
14
14
  const { isMobile } = useViewportType();
15
15
  const hoverTimerRef = useRef(null);
16
16
  const theme = useTheme();
@@ -80,9 +80,6 @@ export const useLogic = (props) => {
80
80
  }
81
81
  };
82
82
  }, [collapsedIn, isPinned]);
83
- const wrapperClassnames = useMemo(() => classNames({
84
- [dashboardSidebarClassnames.hasMenuOrganization]: hasMenuOrganizationRef.current,
85
- }), [hasMenuOrganizationRef.current]);
86
83
  const classnames = classNames(className, dashboardSidebarClassnames.root);
87
84
  return {
88
85
  isPinned,
@@ -96,6 +93,8 @@ export const useLogic = (props) => {
96
93
  header,
97
94
  isLoading: isLoading || isDashboardLoading,
98
95
  classnames,
99
- wrapperClassnames,
96
+ hasMenuOrganization: hasMenuOrganizationRef.current &&
97
+ mobileHeaderPriorityFeature === 'profile',
98
+ hasProfile: hasProfileRef.current && mobileHeaderPriorityFeature === 'menuOrg',
100
99
  };
101
100
  };
@@ -13,7 +13,7 @@ export const OrganizationButton = forwardRef(({ onClick, isOpen, currentOrganiza
13
13
  });
14
14
  const renderButton = () => (_jsx(StyledButton, { ref: ref, variant: "text", disabled: isDisabled, onClick: onClick, className: menuOrganizationClassnames.button, endIcon: _jsx(StyledChevron, { isActive: isOpen, width: 24, height: 24 }), children: renderPreview ? (renderPreview(currentOrganization, {
15
15
  className: hidePersonalDataClassname,
16
- })) : (_jsxs(Container, { className: hidePersonalDataClassname, children: [_jsx(OverflowTypography, { variant: "h6", component: "div", children: name }), _jsxs(OrganizationData, { children: [_jsxs(StyledTypography, { "$isDisabled": isDisabled, variant: "caption", color: "textSecondary", children: ["\u0418\u041D\u041D ", inn] }), kpp && (_jsxs(StyledTypography, { "$isDisabled": isDisabled, variant: "caption", color: "textSecondary", children: ["\u041A\u041F\u041F ", kpp] }))] })] })) }));
16
+ })) : (_jsxs(Container, { className: hidePersonalDataClassname, children: [_jsx(OverflowTypography, { variant: "h6", component: "div", children: name }), _jsxs(OrganizationData, { className: menuOrganizationClassnames.organizationData, children: [_jsxs(StyledTypography, { "$isDisabled": isDisabled, variant: "caption", color: "textSecondary", children: ["\u0418\u041D\u041D ", inn] }), kpp && (_jsxs(StyledTypography, { "$isDisabled": isDisabled, variant: "caption", color: "textSecondary", children: ["\u041A\u041F\u041F ", kpp] }))] })] })) }));
17
17
  if (isDisabled && disabledReason) {
18
18
  return (_jsx(Tooltip, { title: disabledReason, withoutContainer: false, placement: "bottom", children: renderButton() }));
19
19
  }
@@ -5,4 +5,5 @@ export declare const menuOrganizationClassnames: {
5
5
  root: string;
6
6
  errorPlaceholder: string;
7
7
  button: string;
8
+ organizationData: string;
8
9
  };
@@ -6,4 +6,5 @@ export const menuOrganizationClassnames = {
6
6
  root: createUIKitClassname('menu-organization'),
7
7
  errorPlaceholder: createUIKitClassname('menu-organization__error-placeholder'),
8
8
  button: createUIKitClassname('menu-organization__button'),
9
+ organizationData: createUIKitClassname('menu-organization__organization-data'),
9
10
  };
@@ -23,7 +23,7 @@ export const Profile = (props) => {
23
23
  if (isLoading) {
24
24
  return _jsx(ProfileSkeleton, {});
25
25
  }
26
- return (_jsxs(_Fragment, { children: [_jsx(ClickAwayListener, { onClickAway: handleCloseMenu, children: _jsxs(ProfileRoot, { ref: anchorRef, variant: "text", onClick: handleOpenMenu, children: [_jsx(StyledAvatar, { ...avatar }), _jsxs(User, { children: [_jsxs(Credentials, { className: hidePersonalDataClassname, children: [_jsx(Typography, { variant: "body1", className: profileClassnames.credentials, children: displayName }), _jsx(Typography, { variant: "caption", color: "textSecondary", className: profileClassnames.credentials, children: annotation })] }), _jsx(StyledChevron, { isActive: open })] })] }) }), Menu ? (_jsx(Menu, { open: open, anchorEl: anchorRef.current, onClose: handleCloseMenu, anchorOrigin: {
26
+ return (_jsxs(_Fragment, { children: [_jsx(ClickAwayListener, { onClickAway: handleCloseMenu, children: _jsxs(ProfileRoot, { ref: anchorRef, variant: "text", onClick: handleOpenMenu, className: profileClassnames.button, children: [_jsx(StyledAvatar, { ...avatar, className: profileClassnames.avatar }), _jsxs(User, { className: profileClassnames.user, children: [_jsxs(Credentials, { className: hidePersonalDataClassname, children: [_jsx(Typography, { variant: "body1", className: profileClassnames.credentials, children: displayName }), _jsx(Typography, { variant: "caption", color: "textSecondary", className: profileClassnames.credentials, children: annotation })] }), _jsx(StyledChevron, { isActive: open })] })] }) }), Menu ? (_jsx(Menu, { open: open, anchorEl: anchorRef.current, onClose: handleCloseMenu, anchorOrigin: {
27
27
  vertical: 'bottom',
28
28
  horizontal: 'right',
29
29
  }, transformOrigin: {
@@ -1,3 +1,6 @@
1
1
  export declare const profileClassnames: {
2
2
  credentials: string;
3
+ button: string;
4
+ avatar: string;
5
+ user: string;
3
6
  };
@@ -1,4 +1,7 @@
1
1
  import { createUIKitClassname } from '../utils/createUIKitClassname';
2
2
  export const profileClassnames = {
3
3
  credentials: createUIKitClassname('profile__credentials'),
4
+ button: createUIKitClassname('profile__button'),
5
+ avatar: createUIKitClassname('profile__avatar'),
6
+ user: createUIKitClassname('profile__user'),
4
7
  };
@@ -1,10 +1,12 @@
1
1
  import { type RefObject } from 'react';
2
2
  export type DashboardContextProps = {
3
3
  isFocusedMode: boolean;
4
+ mobileHeaderPriorityFeature: 'profile' | 'menuOrg';
4
5
  setAlertElement?: (element: HTMLElement | null) => void;
5
6
  alertHeight: number;
6
7
  isLoading: boolean;
7
8
  hasMenuOrganizationRef: RefObject<boolean | null>;
9
+ hasProfileRef: RefObject<boolean | null>;
8
10
  setFocusedMode: (isFocusedMode: boolean) => void;
9
11
  };
10
12
  export declare const DashboardContext: import("react").Context<DashboardContextProps>;
@@ -4,8 +4,10 @@ exports.DashboardContext = void 0;
4
4
  const react_1 = require("react");
5
5
  exports.DashboardContext = (0, react_1.createContext)({
6
6
  isFocusedMode: false,
7
+ mobileHeaderPriorityFeature: 'menuOrg',
7
8
  alertHeight: 0,
8
9
  isLoading: false,
9
10
  hasMenuOrganizationRef: (0, react_1.createRef)(),
11
+ hasProfileRef: (0, react_1.createRef)(),
10
12
  setFocusedMode: () => undefined,
11
13
  });
@@ -1,8 +1,8 @@
1
1
  import { type ReactNode } from 'react';
2
2
  import { type DashboardContextProps } from '../DashboardContext';
3
- type Props = Pick<DashboardContextProps, 'isFocusedMode'> & {
3
+ type Props = Pick<DashboardContextProps, 'isFocusedMode' | 'mobileHeaderPriorityFeature'> & {
4
4
  children: ReactNode;
5
5
  isLoading: boolean;
6
6
  };
7
- export declare const DashboardContextProvider: ({ children, isFocusedMode, isLoading, }: Props) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const DashboardContextProvider: ({ children, isFocusedMode, isLoading, mobileHeaderPriorityFeature, }: Props) => import("react/jsx-runtime").JSX.Element;
8
8
  export {};
@@ -4,11 +4,12 @@ exports.DashboardContextProvider = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const DashboardContext_1 = require("../DashboardContext");
7
- const DashboardContextProvider = ({ children, isFocusedMode, isLoading, }) => {
7
+ const DashboardContextProvider = ({ children, isFocusedMode, isLoading, mobileHeaderPriorityFeature, }) => {
8
8
  const [alertElement, setAlertElement] = (0, react_1.useState)(null);
9
9
  const [alertHeight, setAlertHeight] = (0, react_1.useState)(0);
10
10
  const [isFocusedModeInternal, setFocusedMode] = (0, react_1.useState)(isFocusedMode);
11
11
  const hasMenuOrganizationRef = (0, react_1.useRef)(false);
12
+ const hasProfileRef = (0, react_1.useRef)(false);
12
13
  (0, react_1.useEffect)(() => {
13
14
  if (isFocusedMode !== isFocusedModeInternal) {
14
15
  setFocusedMode(isFocusedMode);
@@ -30,9 +31,11 @@ const DashboardContextProvider = ({ children, isFocusedMode, isLoading, }) => {
30
31
  }, [alertElement]);
31
32
  return ((0, jsx_runtime_1.jsx)(DashboardContext_1.DashboardContext.Provider, { value: {
32
33
  isFocusedMode: isFocusedModeInternal,
34
+ mobileHeaderPriorityFeature,
33
35
  setAlertElement,
34
36
  alertHeight,
35
37
  isLoading,
38
+ hasProfileRef,
36
39
  hasMenuOrganizationRef,
37
40
  setFocusedMode,
38
41
  }, children: children }));
@@ -4,7 +4,7 @@ import { type DashboardLayoutProps } from './types';
4
4
  * Общий Layout приложения
5
5
  */
6
6
  export declare const DashboardLayout: {
7
- ({ children, isFocusedMode, isLoading, }: DashboardLayoutProps): import("react/jsx-runtime").JSX.Element;
7
+ ({ children, isFocusedMode, isLoading, mobileHeaderPriorityFeature, }: DashboardLayoutProps): import("react/jsx-runtime").JSX.Element;
8
8
  Header: import("react").ForwardRefExoticComponent<import("./Header").HeaderProps & import("react").RefAttributes<HTMLDivElement>>;
9
9
  Sidebar: import("react").ForwardRefExoticComponent<import("../DashboardSidebar").DashboardSidebarProps & import("react").RefAttributes<HTMLBaseElement>>;
10
10
  Main: import("react").ForwardRefExoticComponent<import("./Main").MainProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -10,8 +10,8 @@ const Main_1 = require("./Main");
10
10
  /**
11
11
  * Общий Layout приложения
12
12
  */
13
- const DashboardLayout = ({ children, isFocusedMode = false, isLoading = false, }) => {
14
- return ((0, jsx_runtime_1.jsx)(DashboardContext_1.DashboardContextProvider, { isFocusedMode: isFocusedMode, isLoading: isLoading, children: (0, jsx_runtime_1.jsx)(DashboardWrapper_1.DashboardWrapper, { children: children }) }));
13
+ const DashboardLayout = ({ children, isFocusedMode = false, isLoading = false, mobileHeaderPriorityFeature = 'menuOrg', }) => {
14
+ return ((0, jsx_runtime_1.jsx)(DashboardContext_1.DashboardContextProvider, { isFocusedMode: isFocusedMode, isLoading: isLoading, mobileHeaderPriorityFeature: mobileHeaderPriorityFeature, children: (0, jsx_runtime_1.jsx)(DashboardWrapper_1.DashboardWrapper, { children: children }) }));
15
15
  };
16
16
  exports.DashboardLayout = DashboardLayout;
17
17
  exports.DashboardLayout.Header = Header_1.Header;
@@ -9,15 +9,40 @@ const QuitOutlineMd_1 = require("../../../icons/QuitOutlineMd");
9
9
  const Button_1 = require("../../Button");
10
10
  const Product_1 = require("../../Product");
11
11
  const Profile_1 = require("../../Profile");
12
+ const cva_1 = require("../../utils/cva");
12
13
  const getInertProps_1 = require("../../utils/getInertProps");
13
14
  const constants_1 = require("./constants");
14
15
  const styles_1 = require("./styles");
15
16
  const useLogic_1 = require("./useLogic");
17
+ const headerPriorityFeature = (0, cva_1.cva)('', {
18
+ variants: {
19
+ feature: {
20
+ menuOrg: constants_1.dashboardLayoutHeaderClassnames.priorityFeatureMenuOrg,
21
+ profile: constants_1.dashboardLayoutHeaderClassnames.priorityFeatureProfile,
22
+ },
23
+ isPinned: {
24
+ true: constants_1.dashboardLayoutHeaderClassnames.mobileSidebarPriorityFeatureVisible,
25
+ },
26
+ featureInSidebar: {
27
+ true: constants_1.dashboardLayoutHeaderClassnames.featureInSidebar,
28
+ },
29
+ },
30
+ });
16
31
  /**
17
32
  * Основной header приложения
18
33
  */
19
34
  exports.Header = (0, react_1.forwardRef)((props, ref) => {
20
35
  const { productSwitcher: ProductSwitcher, product, profile, menuOrganization, children, } = props;
21
- const { isShowExitButton, isShowProfile, isFocusedMode, isMobile, collapsedIn, onToggleSidebar, isLoading, alertHeight, menuOrganizationClassnames, } = (0, useLogic_1.useLogic)(props);
22
- return ((0, jsx_runtime_1.jsx)(styles_1.HeaderRoot, { ref: ref, "$isFocusedMode": isFocusedMode, ...(0, getInertProps_1.getInertProps)(!isMobile && isFocusedMode), className: constants_1.dashboardLayoutHeaderClassnames.root, children: (0, jsx_runtime_1.jsxs)(styles_1.HeaderContent, { children: [(0, jsx_runtime_1.jsx)(styles_1.MobileSidebarTogglerWrapper, { className: constants_1.dashboardLayoutHeaderClassnames.mobileSidebarButton, children: (0, jsx_runtime_1.jsx)(Button_1.Button, { startIcon: collapsedIn ? (0, jsx_runtime_1.jsx)(CrossOutlineMd_1.CrossOutlineMd, {}) : (0, jsx_runtime_1.jsx)(MenuOnOutlineMd_1.MenuOnOutlineMd, {}), variant: "text", onClick: () => onToggleSidebar(), title: "\u041F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C \u0431\u043E\u043A\u043E\u0432\u043E\u0435 \u043C\u0435\u043D\u044E" }) }), (0, jsx_runtime_1.jsxs)(styles_1.HeaderSection, { children: [ProductSwitcher && ((0, jsx_runtime_1.jsx)(styles_1.ProductSwitcherWrapper, { children: (0, jsx_runtime_1.jsx)(ProductSwitcher, {}) })), (0, jsx_runtime_1.jsx)(Product_1.Product, { ...product })] }), (0, jsx_runtime_1.jsxs)(styles_1.HeaderContentSection, { children: [children, menuOrganization && ((0, jsx_runtime_1.jsx)(styles_1.MenuOrganizationWrapper, { className: menuOrganizationClassnames, "$alertHeight": alertHeight, children: menuOrganization() })), profile && ((0, jsx_runtime_1.jsx)(styles_1.ProfileWrapper, { "$isShow": isShowProfile, children: (0, jsx_runtime_1.jsx)(Profile_1.Profile, { isLoading: isLoading, ...profile }) })), (0, jsx_runtime_1.jsx)(styles_1.ExitButton, { "$isShow": isShowExitButton, onClick: profile?.exitButton?.onClick, title: "\u0412\u044B\u0445\u043E\u0434", variant: "text", children: (0, jsx_runtime_1.jsx)(QuitOutlineMd_1.QuitOutlineMd, {}) })] })] }) }));
36
+ const { isShowExitButton, isShowProfile, isFocusedMode, isMobile, collapsedIn, onToggleSidebar, isLoading, mobileHeaderPriorityFeature, headerStyle, isPinned, } = (0, useLogic_1.useLogic)(props);
37
+ return ((0, jsx_runtime_1.jsx)(styles_1.HeaderRoot, { ref: ref, "$isFocusedMode": isFocusedMode, ...(0, getInertProps_1.getInertProps)(!isMobile && isFocusedMode), className: constants_1.dashboardLayoutHeaderClassnames.root, style: headerStyle, children: (0, jsx_runtime_1.jsxs)(styles_1.HeaderContent, { children: [(0, jsx_runtime_1.jsx)(styles_1.MobileSidebarTogglerWrapper, { className: constants_1.dashboardLayoutHeaderClassnames.mobileSidebarButton, children: (0, jsx_runtime_1.jsx)(Button_1.Button, { startIcon: collapsedIn ? (0, jsx_runtime_1.jsx)(CrossOutlineMd_1.CrossOutlineMd, {}) : (0, jsx_runtime_1.jsx)(MenuOnOutlineMd_1.MenuOnOutlineMd, {}), variant: "text", onClick: () => onToggleSidebar(), title: "\u041F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C \u0431\u043E\u043A\u043E\u0432\u043E\u0435 \u043C\u0435\u043D\u044E" }) }), (0, jsx_runtime_1.jsxs)(styles_1.HeaderSection, { children: [ProductSwitcher && ((0, jsx_runtime_1.jsx)(styles_1.ProductSwitcherWrapper, { children: (0, jsx_runtime_1.jsx)(ProductSwitcher, {}) })), (0, jsx_runtime_1.jsx)(Product_1.Product, { ...product })] }), (0, jsx_runtime_1.jsxs)(styles_1.HeaderContentSection, { className: headerPriorityFeature({
38
+ feature: mobileHeaderPriorityFeature,
39
+ }), children: [children, menuOrganization && ((0, jsx_runtime_1.jsx)(styles_1.PriorityFeatureWrapper, { className: headerPriorityFeature({
40
+ feature: mobileHeaderPriorityFeature,
41
+ isPinned,
42
+ featureInSidebar: mobileHeaderPriorityFeature === 'profile',
43
+ }), children: menuOrganization() })), profile && ((0, jsx_runtime_1.jsx)(styles_1.PriorityFeatureWrapper, { className: headerPriorityFeature({
44
+ feature: mobileHeaderPriorityFeature,
45
+ isPinned,
46
+ featureInSidebar: mobileHeaderPriorityFeature === 'menuOrg',
47
+ }), children: (0, jsx_runtime_1.jsx)(styles_1.ProfileWrapper, { className: constants_1.dashboardLayoutHeaderClassnames.profile, "$isShow": isShowProfile, children: (0, jsx_runtime_1.jsx)(Profile_1.Profile, { isLoading: isLoading, ...profile }) }) })), (0, jsx_runtime_1.jsx)(styles_1.ExitButton, { "$isShow": isShowExitButton, onClick: profile?.exitButton?.onClick, title: "\u0412\u044B\u0445\u043E\u0434", variant: "text", children: (0, jsx_runtime_1.jsx)(QuitOutlineMd_1.QuitOutlineMd, {}) })] })] }) }));
23
48
  });
@@ -1,5 +1,9 @@
1
1
  export declare const dashboardLayoutHeaderClassnames: {
2
2
  root: string;
3
3
  mobileSidebarButton: string;
4
- mobileMenuOrganizationVisible: string;
4
+ priorityFeatureMenuOrg: string;
5
+ priorityFeatureProfile: string;
6
+ mobileSidebarPriorityFeatureVisible: string;
7
+ featureInSidebar: string;
8
+ profile: string;
5
9
  };
@@ -5,5 +5,9 @@ const createUIKitClassname_1 = require("../../utils/createUIKitClassname");
5
5
  exports.dashboardLayoutHeaderClassnames = {
6
6
  root: (0, createUIKitClassname_1.createUIKitClassname)('dashboard-layout-header'),
7
7
  mobileSidebarButton: (0, createUIKitClassname_1.createUIKitClassname)('dashboard-layout-header__sidebar-button_mobile'),
8
- mobileMenuOrganizationVisible: (0, createUIKitClassname_1.createUIKitClassname)('dashboard-layout-header__menu-organization_visible'),
8
+ priorityFeatureMenuOrg: (0, createUIKitClassname_1.createUIKitClassname)('dashboard-layout-header__priority-feature_menu-org'),
9
+ priorityFeatureProfile: (0, createUIKitClassname_1.createUIKitClassname)('dashboard-layout-header__priority-feature_profile'),
10
+ mobileSidebarPriorityFeatureVisible: (0, createUIKitClassname_1.createUIKitClassname)('dashboard-layout-header__sidebar-priority-feature_visible'),
11
+ featureInSidebar: (0, createUIKitClassname_1.createUIKitClassname)('dashboard-layout-header__feature-in-sidebar'),
12
+ profile: (0, createUIKitClassname_1.createUIKitClassname)('dashboard-layout-header__profile'),
9
13
  };
@@ -44,9 +44,10 @@ export declare const HeaderContent: import("@emotion/styled/dist/declarations/sr
44
44
  theme?: import("@emotion/react").Theme | undefined;
45
45
  as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
46
46
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
47
- export declare const MenuOrganizationWrapper: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
47
+ /**
48
+ * Обертка для элементов которые должны быть в мобильном хедере или помещены в sidebar.
49
+ */
50
+ export declare const PriorityFeatureWrapper: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
48
51
  theme?: import("@emotion/react").Theme | undefined;
49
52
  as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
50
- } & {
51
- $alertHeight?: number | undefined;
52
53
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -1,14 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MenuOrganizationWrapper = exports.HeaderContent = exports.ExitButton = exports.ProfileWrapper = exports.ProductSwitcherWrapper = exports.HeaderContentSection = exports.HeaderSection = exports.MobileSidebarTogglerWrapper = exports.HeaderRoot = void 0;
3
+ exports.PriorityFeatureWrapper = exports.HeaderContent = exports.ExitButton = exports.ProfileWrapper = exports.ProductSwitcherWrapper = exports.HeaderContentSection = exports.HeaderSection = exports.MobileSidebarTogglerWrapper = exports.HeaderRoot = void 0;
4
4
  const Button_1 = require("@mui/material/Button");
5
5
  const constants_1 = require("../../DashboardSidebar/constants");
6
6
  const IconButton_1 = require("../../IconButton");
7
7
  const constants_2 = require("../../MenuOrganization/constants");
8
8
  const constants_3 = require("../../MenuOrganization/OrganizationButton/constants");
9
+ const constants_4 = require("../../Profile/constants");
9
10
  const styled_1 = require("../../styled");
10
- const constants_4 = require("../constants");
11
- const constants_5 = require("./constants");
11
+ const constants_5 = require("../constants");
12
+ const constants_6 = require("./constants");
12
13
  exports.HeaderRoot = (0, styled_1.styled)('header', {
13
14
  shouldForwardProp: (prop) => !['$isFocusedMode'].includes(prop),
14
15
  }) `
@@ -21,8 +22,8 @@ exports.HeaderRoot = (0, styled_1.styled)('header', {
21
22
  justify-content: space-between;
22
23
 
23
24
  width: 100%;
24
- height: ${constants_4.HEADER_HEIGHT_DESKTOP};
25
- margin-top: ${({ $isFocusedMode }) => $isFocusedMode ? `-${constants_4.HEADER_HEIGHT_DESKTOP}` : 0};
25
+ height: ${constants_5.HEADER_HEIGHT_DESKTOP};
26
+ margin-top: ${({ $isFocusedMode }) => $isFocusedMode ? `-${constants_5.HEADER_HEIGHT_DESKTOP}` : 0};
26
27
  margin-bottom: ${({ theme }) => theme.spacing(4)};
27
28
 
28
29
  transition: ${({ theme }) => {
@@ -32,14 +33,14 @@ exports.HeaderRoot = (0, styled_1.styled)('header', {
32
33
  }};
33
34
 
34
35
  ${({ theme }) => theme.breakpoints.down('laptop')} {
35
- height: ${constants_4.HEADER_HEIGHT_LAPTOP};
36
+ height: ${constants_5.HEADER_HEIGHT_LAPTOP};
36
37
  }
37
38
 
38
39
  ${({ theme }) => theme.breakpoints.down('sm')} {
39
40
  grid-row: 2;
40
41
  justify-content: flex-start;
41
42
 
42
- height: ${constants_4.HEADER_HEIGHT_MOBILE};
43
+ height: ${constants_5.HEADER_HEIGHT_MOBILE};
43
44
  margin-bottom: 0;
44
45
  padding: ${({ theme }) => theme.spacing(0, 2, 0, 1)};
45
46
 
@@ -60,7 +61,7 @@ exports.MobileSidebarTogglerWrapper = styled_1.styled.div `
60
61
 
61
62
  /* Причина игнора: Не критично для отображения */
62
63
  /* stylelint-disable-next-line plugin/no-unsupported-browser-features */
63
- .${constants_4.dashboardLayoutClassnames.root}:not(:has(.${constants_1.dashboardSidebarClassnames.root}))
64
+ .${constants_5.dashboardLayoutClassnames.root}:not(:has(.${constants_1.dashboardSidebarClassnames.root}))
64
65
  & {
65
66
  display: none;
66
67
  }
@@ -80,6 +81,15 @@ exports.HeaderContentSection = (0, styled_1.styled)(exports.HeaderSection) `
80
81
 
81
82
  ${({ theme }) => theme.breakpoints.down('sm')} {
82
83
  gap: ${({ theme }) => theme.spacing(2)};
84
+
85
+ &.${constants_6.dashboardLayoutHeaderClassnames.priorityFeatureMenuOrg} {
86
+ & .${constants_2.menuOrganizationClassnames.organizationData} {
87
+ display: none;
88
+ }
89
+ & .${constants_2.menuOrganizationClassnames.button} {
90
+ border-radius: ${({ theme }) => theme.shape.medium};
91
+ }
92
+ }
83
93
  }
84
94
  `;
85
95
  exports.ProductSwitcherWrapper = styled_1.styled.div `
@@ -114,45 +124,77 @@ exports.HeaderContent = styled_1.styled.div `
114
124
  padding: 0;
115
125
  }
116
126
  `;
117
- exports.MenuOrganizationWrapper = styled_1.styled.div `
127
+ /**
128
+ * Обертка для элементов которые должны быть в мобильном хедере или помещены в sidebar.
129
+ */
130
+ exports.PriorityFeatureWrapper = styled_1.styled.div `
118
131
  ${({ theme }) => theme.breakpoints.down('sm')} {
119
- position: absolute;
120
- z-index: ${({ theme }) => theme.zIndex.appBar - 1};
121
- top: ${({ $alertHeight }) => `calc(${$alertHeight}px + ${constants_4.HEADER_HEIGHT_MOBILE}) `};
122
- left: 0;
123
-
124
- /* Необходимо для анимации компонента вместе с sidebar */
125
- transform: translateX(-100vw);
126
132
 
127
- display: flex;
128
- flex-direction: column;
133
+ &.${constants_6.dashboardLayoutHeaderClassnames.featureInSidebar} {
134
+ position: absolute;
135
+ z-index: ${({ theme }) => theme.zIndex.appBar - 1};
136
+ top: calc(var(--alert-height, 0px) + ${constants_5.HEADER_HEIGHT_MOBILE});
137
+ left: 0;
138
+
139
+ /* Необходимо для анимации компонента вместе с sidebar */
140
+ transform: translateX(-100vw);
129
141
 
130
- width: 100vw;
142
+ display: flex;
143
+ flex-direction: column;
131
144
 
132
- background-color: ${({ theme }) => theme.palette.background.default};
145
+ width: 100vw;
133
146
 
134
- transition: ${({ theme }) => {
147
+ background-color: ${({ theme }) => theme.palette.background.default};
148
+
149
+ transition: ${({ theme }) => {
135
150
  return theme.transitions.create(['transform'], {
136
151
  duration: theme.transitions.duration.standard,
137
152
  });
138
153
  }};
139
154
 
140
- &.${constants_5.dashboardLayoutHeaderClassnames.mobileMenuOrganizationVisible} {
141
- transform: translateX(0);
142
- }
143
-
144
- & .${constants_2.menuOrganizationClassnames.button} {
145
- height: ${constants_3.MOBILE_BUTTON_HEIGHT};
146
- padding: ${({ theme }) => theme.spacing(3, 4)};
155
+ &.${constants_6.dashboardLayoutHeaderClassnames.mobileSidebarPriorityFeatureVisible} {
156
+ transform: translateX(0);
157
+ }
147
158
 
148
- border-bottom: 1px solid ${({ theme }) => theme.palette.grey[300]};
159
+ & .${constants_2.menuOrganizationClassnames.button}, & .${constants_4.profileClassnames.button} {
160
+ height: ${constants_3.MOBILE_BUTTON_HEIGHT};
161
+ padding: ${({ theme }) => theme.spacing(3, 4)};
149
162
 
150
- &:hover {
151
163
  border-bottom: 1px solid ${({ theme }) => theme.palette.grey[300]};
164
+
165
+ &:hover {
166
+ border-bottom: 1px solid ${({ theme }) => theme.palette.grey[300]};
167
+ }
168
+
169
+ &:active {
170
+ border-bottom: 1px solid ${({ theme }) => theme.palette.grey[300]};
171
+ }
152
172
  }
153
173
 
154
- &:active {
155
- border-bottom: 1px solid ${({ theme }) => theme.palette.grey[300]};
174
+ &.${constants_6.dashboardLayoutHeaderClassnames.priorityFeatureMenuOrg} {
175
+ & .${constants_6.dashboardLayoutHeaderClassnames.profile} {
176
+ display: block;
177
+ }
178
+
179
+
180
+ & .${constants_4.profileClassnames.button} {
181
+ width: 100%;
182
+ max-width: unset;
183
+
184
+ border-radius: 0;
185
+ }
186
+
187
+ & .${constants_4.profileClassnames.avatar} {
188
+ display: none;
189
+ }
190
+
191
+ & .${constants_4.profileClassnames.user} {
192
+ display: flex;
193
+ align-items: center;
194
+ justify-content: space-between;
195
+
196
+ width: 100%;
197
+ }
156
198
  }
157
199
  }
158
200
  }
@@ -1,12 +1,15 @@
1
+ import { type CSSProperties } from 'react';
1
2
  import { type HeaderProps } from '../types';
2
3
  export declare const useLogic: ({ profile, menuOrganization }: HeaderProps) => {
3
4
  isShowExitButton: boolean;
4
5
  isShowProfile: boolean;
5
6
  isMobile: boolean;
6
7
  isFocusedMode: boolean;
8
+ mobileHeaderPriorityFeature: "profile" | "menuOrg";
7
9
  isLoading: boolean;
8
10
  collapsedIn: boolean;
9
11
  onToggleSidebar: (newValue?: boolean | undefined) => void;
10
12
  alertHeight: number;
11
- menuOrganizationClassnames: string;
13
+ isPinned: boolean;
14
+ headerStyle: CSSProperties;
12
15
  };
@@ -5,31 +5,36 @@ const react_1 = require("react");
5
5
  const DashboardContext_1 = require("../../../DashboardContext");
6
6
  const DashboardSidebarProvider_1 = require("../../../DashboardSidebarProvider");
7
7
  const useViewportType_1 = require("../../../useViewportType");
8
- const classNames_1 = require("../../../utils/classNames");
9
- const constants_1 = require("../constants");
10
8
  const useLogic = ({ profile, menuOrganization }) => {
11
- const { isFocusedMode, isLoading, hasMenuOrganizationRef, alertHeight } = (0, react_1.useContext)(DashboardContext_1.DashboardContext);
9
+ const { isFocusedMode, isLoading, hasMenuOrganizationRef, hasProfileRef, alertHeight, mobileHeaderPriorityFeature, } = (0, react_1.useContext)(DashboardContext_1.DashboardContext);
12
10
  const { collapsedIn, onToggleSidebar, isPinned } = (0, react_1.useContext)(DashboardSidebarProvider_1.DashboardSidebarContext);
13
11
  (0, react_1.useEffect)(() => {
14
12
  hasMenuOrganizationRef.current = Boolean(menuOrganization);
15
- }, [menuOrganization]);
13
+ hasProfileRef.current = Boolean(profile);
14
+ }, [menuOrganization, profile]);
16
15
  const { isMobile } = (0, useViewportType_1.useViewportType)();
17
16
  const hasMenu = Boolean(profile?.menu || profile?.menuList);
18
- const isShowProfile = (Boolean(profile) && !isMobile) || (hasMenu && isMobile);
19
- const isShowExitButton = isMobile && !hasMenu && Boolean(profile?.exitButton);
20
- const menuOrganizationClassnames = (0, react_1.useMemo)(() => (0, classNames_1.classNames)({
21
- [constants_1.dashboardLayoutHeaderClassnames.mobileMenuOrganizationVisible]: isPinned,
22
- }), [isPinned]);
17
+ const isShowProfile = (Boolean(profile) && !isMobile) ||
18
+ (hasMenu && isMobile && mobileHeaderPriorityFeature === 'profile');
19
+ const isShowExitButton = isMobile &&
20
+ !hasMenu &&
21
+ Boolean(profile?.exitButton) &&
22
+ mobileHeaderPriorityFeature === 'profile';
23
+ const headerStyle = {
24
+ '--alert-height': `${alertHeight}px`,
25
+ };
23
26
  return {
24
27
  isShowExitButton,
25
28
  isShowProfile,
26
29
  isMobile,
27
30
  isFocusedMode,
31
+ mobileHeaderPriorityFeature,
28
32
  isLoading,
29
33
  collapsedIn,
30
34
  onToggleSidebar,
31
35
  alertHeight,
32
- menuOrganizationClassnames,
36
+ isPinned,
37
+ headerStyle,
33
38
  };
34
39
  };
35
40
  exports.useLogic = useLogic;
@@ -10,4 +10,9 @@ export type DashboardLayoutProps = {
10
10
  * Если true, отображается состояние загрузки
11
11
  */
12
12
  isLoading?: boolean;
13
+ /**
14
+ * Элемент, отображаемый в мобильном хедере.
15
+ * Второстепенный будет помещен в sidebar.
16
+ */
17
+ mobileHeaderPriorityFeature?: 'profile' | 'menuOrg';
13
18
  };
@@ -6,17 +6,32 @@ const react_1 = require("react");
6
6
  const DashboardSidebarSkeleton_1 = require("../DashboardSidebarSkeleton");
7
7
  const NavMenu_1 = require("../NavMenu");
8
8
  const PinButton_1 = require("../PinButton");
9
+ const cva_1 = require("../utils/cva");
9
10
  const getInertProps_1 = require("../utils/getInertProps");
11
+ const constants_1 = require("./constants");
10
12
  const SidebarNav_1 = require("./SidebarNav");
11
13
  const styles_1 = require("./styles");
12
14
  const useLogic_1 = require("./useLogic");
15
+ const sidebar = (0, cva_1.cva)('', {
16
+ variants: {
17
+ hasProfile: {
18
+ true: constants_1.dashboardSidebarClassnames.hasProfile,
19
+ },
20
+ hasMenuOrganization: {
21
+ true: constants_1.dashboardSidebarClassnames.hasMenuOrganization,
22
+ },
23
+ },
24
+ });
13
25
  /**
14
26
  * Основной sidebar приложения
15
27
  */
16
28
  exports.DashboardSidebar = (0, react_1.forwardRef)((props, ref) => {
17
- const { isPinned, isMobile, collapsedIn, onTogglePin, onMouseEnter, onMouseLeave, alertHeight, classnames, wrapperClassnames, menu, header, isLoading, } = (0, useLogic_1.useLogic)(props);
29
+ const { isPinned, isMobile, collapsedIn, onTogglePin, onMouseEnter, onMouseLeave, alertHeight, classnames, menu, header, isLoading, hasMenuOrganization, hasProfile, } = (0, useLogic_1.useLogic)(props);
18
30
  if (isLoading) {
19
31
  return (0, jsx_runtime_1.jsx)(DashboardSidebarSkeleton_1.DashboardSidebarSkeleton, {});
20
32
  }
21
- return ((0, jsx_runtime_1.jsx)(styles_1.Wrapper, { "$isPinned": isPinned, "$alertHeight": alertHeight, className: wrapperClassnames, children: (0, jsx_runtime_1.jsx)(styles_1.SidebarRoot, { ref: ref, "$isPinned": isPinned, "$collapsedIn": collapsedIn, className: classnames, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, ...(0, getInertProps_1.getInertProps)(isMobile && !isPinned), children: (0, jsx_runtime_1.jsxs)(styles_1.StyledPaper, { variant: "outlined", children: [(0, jsx_runtime_1.jsxs)(styles_1.SidebarContent, { "$collapsedIn": collapsedIn, "$isPinned": isPinned, "$hasHeader": Boolean(header), children: [header && (0, jsx_runtime_1.jsx)(styles_1.SidebarHeader, { children: header }), (0, jsx_runtime_1.jsx)(SidebarNav_1.SidebarNav, { menu: (0, jsx_runtime_1.jsx)(NavMenu_1.NavMenu, { collapsedIn: collapsedIn, items: menu.items }) })] }), (0, jsx_runtime_1.jsx)(styles_1.Footer, { children: (0, jsx_runtime_1.jsx)(PinButton_1.PinButton, { isPinned: isPinned, collapsedIn: collapsedIn, onClick: onTogglePin }) })] }) }) }));
33
+ return ((0, jsx_runtime_1.jsx)(styles_1.Wrapper, { "$isPinned": isPinned, "$alertHeight": alertHeight, className: sidebar({
34
+ hasProfile,
35
+ hasMenuOrganization,
36
+ }), children: (0, jsx_runtime_1.jsx)(styles_1.SidebarRoot, { ref: ref, "$isPinned": isPinned, "$collapsedIn": collapsedIn, className: classnames, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, ...(0, getInertProps_1.getInertProps)(isMobile && !isPinned), children: (0, jsx_runtime_1.jsxs)(styles_1.StyledPaper, { variant: "outlined", children: [(0, jsx_runtime_1.jsxs)(styles_1.SidebarContent, { "$collapsedIn": collapsedIn, "$isPinned": isPinned, "$hasHeader": Boolean(header), children: [header && (0, jsx_runtime_1.jsx)(styles_1.SidebarHeader, { children: header }), (0, jsx_runtime_1.jsx)(SidebarNav_1.SidebarNav, { menu: (0, jsx_runtime_1.jsx)(NavMenu_1.NavMenu, { collapsedIn: collapsedIn, items: menu.items }) })] }), (0, jsx_runtime_1.jsx)(styles_1.Footer, { children: (0, jsx_runtime_1.jsx)(PinButton_1.PinButton, { isPinned: isPinned, collapsedIn: collapsedIn, onClick: onTogglePin }) })] }) }) }));
22
37
  });
@@ -1,5 +1,6 @@
1
1
  export declare const dashboardSidebarClassnames: {
2
2
  root: string;
3
+ hasProfile: string;
3
4
  hasMenuOrganization: string;
4
5
  };
5
6
  export declare const LABEL_WIDTH: {
@@ -4,6 +4,7 @@ exports.LABEL_WIDTH = exports.dashboardSidebarClassnames = void 0;
4
4
  const createUIKitClassname_1 = require("../utils/createUIKitClassname");
5
5
  exports.dashboardSidebarClassnames = {
6
6
  root: (0, createUIKitClassname_1.createUIKitClassname)('dashboard-layout-sidebar'),
7
+ hasProfile: (0, createUIKitClassname_1.createUIKitClassname)('dashboard-layout-sidebar_has-profile'),
7
8
  hasMenuOrganization: (0, createUIKitClassname_1.createUIKitClassname)('dashboard-layout-sidebar_has-menu-organization'),
8
9
  };
9
10
  exports.LABEL_WIDTH = {
@@ -38,7 +38,7 @@ exports.Wrapper = (0, styled_1.styled)('div', {
38
38
  });
39
39
  }};
40
40
 
41
- &.${constants_4.dashboardSidebarClassnames.hasMenuOrganization} {
41
+ &.${constants_4.dashboardSidebarClassnames.hasMenuOrganization}, &.${constants_4.dashboardSidebarClassnames.hasProfile} {
42
42
  top: ${({ $alertHeight }) => `calc(${$alertHeight}px + ${constants_2.HEADER_HEIGHT_MOBILE} + ${OrganizationButton_1.MOBILE_BUTTON_HEIGHT}) `};
43
43
  }
44
44
  }
@@ -28,5 +28,6 @@ export declare const useLogic: (props: DashboardSidebarProps) => {
28
28
  header: import("react").ReactNode;
29
29
  isLoading: boolean;
30
30
  classnames: string;
31
- wrapperClassnames: string;
31
+ hasMenuOrganization: boolean | null;
32
+ hasProfile: boolean | null;
32
33
  };
@@ -13,7 +13,7 @@ const constants_1 = require("../constants");
13
13
  const useLogic = (props) => {
14
14
  const { className, menu, header, isLoading } = props;
15
15
  const { onToggleSidebar, isPinned, onTogglePin, collapsedIn, setIsPopupOpen, } = (0, react_1.useContext)(DashboardSidebarProvider_1.DashboardSidebarContext);
16
- const { alertHeight, isLoading: isDashboardLoading, hasMenuOrganizationRef, } = (0, react_1.useContext)(DashboardContext_1.DashboardContext);
16
+ const { alertHeight, isLoading: isDashboardLoading, hasMenuOrganizationRef, hasProfileRef, mobileHeaderPriorityFeature, } = (0, react_1.useContext)(DashboardContext_1.DashboardContext);
17
17
  const { isMobile } = (0, useViewportType_1.useViewportType)();
18
18
  const hoverTimerRef = (0, react_1.useRef)(null);
19
19
  const theme = (0, useTheme_1.useTheme)();
@@ -83,9 +83,6 @@ const useLogic = (props) => {
83
83
  }
84
84
  };
85
85
  }, [collapsedIn, isPinned]);
86
- const wrapperClassnames = (0, react_1.useMemo)(() => (0, classNames_1.classNames)({
87
- [constants_1.dashboardSidebarClassnames.hasMenuOrganization]: hasMenuOrganizationRef.current,
88
- }), [hasMenuOrganizationRef.current]);
89
86
  const classnames = (0, classNames_1.classNames)(className, constants_1.dashboardSidebarClassnames.root);
90
87
  return {
91
88
  isPinned,
@@ -99,7 +96,9 @@ const useLogic = (props) => {
99
96
  header,
100
97
  isLoading: isLoading || isDashboardLoading,
101
98
  classnames,
102
- wrapperClassnames,
99
+ hasMenuOrganization: hasMenuOrganizationRef.current &&
100
+ mobileHeaderPriorityFeature === 'profile',
101
+ hasProfile: hasProfileRef.current && mobileHeaderPriorityFeature === 'menuOrg',
103
102
  };
104
103
  };
105
104
  exports.useLogic = useLogic;
@@ -16,7 +16,7 @@ exports.OrganizationButton = (0, react_1.forwardRef)(({ onClick, isOpen, current
16
16
  });
17
17
  const renderButton = () => ((0, jsx_runtime_1.jsx)(styles_2.StyledButton, { ref: ref, variant: "text", disabled: isDisabled, onClick: onClick, className: constants_1.menuOrganizationClassnames.button, endIcon: (0, jsx_runtime_1.jsx)(styles_2.StyledChevron, { isActive: isOpen, width: 24, height: 24 }), children: renderPreview ? (renderPreview(currentOrganization, {
18
18
  className: hidePersonalDataClassname,
19
- })) : ((0, jsx_runtime_1.jsxs)(styles_2.Container, { className: hidePersonalDataClassname, children: [(0, jsx_runtime_1.jsx)(OverflowTypography_1.OverflowTypography, { variant: "h6", component: "div", children: name }), (0, jsx_runtime_1.jsxs)(styles_1.OrganizationData, { children: [(0, jsx_runtime_1.jsxs)(styles_2.StyledTypography, { "$isDisabled": isDisabled, variant: "caption", color: "textSecondary", children: ["\u0418\u041D\u041D ", inn] }), kpp && ((0, jsx_runtime_1.jsxs)(styles_2.StyledTypography, { "$isDisabled": isDisabled, variant: "caption", color: "textSecondary", children: ["\u041A\u041F\u041F ", kpp] }))] })] })) }));
19
+ })) : ((0, jsx_runtime_1.jsxs)(styles_2.Container, { className: hidePersonalDataClassname, children: [(0, jsx_runtime_1.jsx)(OverflowTypography_1.OverflowTypography, { variant: "h6", component: "div", children: name }), (0, jsx_runtime_1.jsxs)(styles_1.OrganizationData, { className: constants_1.menuOrganizationClassnames.organizationData, children: [(0, jsx_runtime_1.jsxs)(styles_2.StyledTypography, { "$isDisabled": isDisabled, variant: "caption", color: "textSecondary", children: ["\u0418\u041D\u041D ", inn] }), kpp && ((0, jsx_runtime_1.jsxs)(styles_2.StyledTypography, { "$isDisabled": isDisabled, variant: "caption", color: "textSecondary", children: ["\u041A\u041F\u041F ", kpp] }))] })] })) }));
20
20
  if (isDisabled && disabledReason) {
21
21
  return ((0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: disabledReason, withoutContainer: false, placement: "bottom", children: renderButton() }));
22
22
  }
@@ -5,4 +5,5 @@ export declare const menuOrganizationClassnames: {
5
5
  root: string;
6
6
  errorPlaceholder: string;
7
7
  button: string;
8
+ organizationData: string;
8
9
  };
@@ -9,4 +9,5 @@ exports.menuOrganizationClassnames = {
9
9
  root: (0, createUIKitClassname_1.createUIKitClassname)('menu-organization'),
10
10
  errorPlaceholder: (0, createUIKitClassname_1.createUIKitClassname)('menu-organization__error-placeholder'),
11
11
  button: (0, createUIKitClassname_1.createUIKitClassname)('menu-organization__button'),
12
+ organizationData: (0, createUIKitClassname_1.createUIKitClassname)('menu-organization__organization-data'),
12
13
  };
@@ -29,7 +29,7 @@ const Profile = (props) => {
29
29
  if (isLoading) {
30
30
  return (0, jsx_runtime_1.jsx)(ProfileSkeleton_1.ProfileSkeleton, {});
31
31
  }
32
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ClickAwayListener_1.default, { onClickAway: handleCloseMenu, children: (0, jsx_runtime_1.jsxs)(styles_1.ProfileRoot, { ref: anchorRef, variant: "text", onClick: handleOpenMenu, children: [(0, jsx_runtime_1.jsx)(styles_1.StyledAvatar, { ...avatar }), (0, jsx_runtime_1.jsxs)(styles_1.User, { children: [(0, jsx_runtime_1.jsxs)(styles_1.Credentials, { className: hidePersonalDataClassname, children: [(0, jsx_runtime_1.jsx)(Typography_1.Typography, { variant: "body1", className: constants_1.profileClassnames.credentials, children: displayName }), (0, jsx_runtime_1.jsx)(Typography_1.Typography, { variant: "caption", color: "textSecondary", className: constants_1.profileClassnames.credentials, children: annotation })] }), (0, jsx_runtime_1.jsx)(styles_1.StyledChevron, { isActive: open })] })] }) }), Menu ? ((0, jsx_runtime_1.jsx)(Menu, { open: open, anchorEl: anchorRef.current, onClose: handleCloseMenu, anchorOrigin: {
32
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ClickAwayListener_1.default, { onClickAway: handleCloseMenu, children: (0, jsx_runtime_1.jsxs)(styles_1.ProfileRoot, { ref: anchorRef, variant: "text", onClick: handleOpenMenu, className: constants_1.profileClassnames.button, children: [(0, jsx_runtime_1.jsx)(styles_1.StyledAvatar, { ...avatar, className: constants_1.profileClassnames.avatar }), (0, jsx_runtime_1.jsxs)(styles_1.User, { className: constants_1.profileClassnames.user, children: [(0, jsx_runtime_1.jsxs)(styles_1.Credentials, { className: hidePersonalDataClassname, children: [(0, jsx_runtime_1.jsx)(Typography_1.Typography, { variant: "body1", className: constants_1.profileClassnames.credentials, children: displayName }), (0, jsx_runtime_1.jsx)(Typography_1.Typography, { variant: "caption", color: "textSecondary", className: constants_1.profileClassnames.credentials, children: annotation })] }), (0, jsx_runtime_1.jsx)(styles_1.StyledChevron, { isActive: open })] })] }) }), Menu ? ((0, jsx_runtime_1.jsx)(Menu, { open: open, anchorEl: anchorRef.current, onClose: handleCloseMenu, anchorOrigin: {
33
33
  vertical: 'bottom',
34
34
  horizontal: 'right',
35
35
  }, transformOrigin: {
@@ -1,3 +1,6 @@
1
1
  export declare const profileClassnames: {
2
2
  credentials: string;
3
+ button: string;
4
+ avatar: string;
5
+ user: string;
3
6
  };
@@ -4,4 +4,7 @@ exports.profileClassnames = void 0;
4
4
  const createUIKitClassname_1 = require("../utils/createUIKitClassname");
5
5
  exports.profileClassnames = {
6
6
  credentials: (0, createUIKitClassname_1.createUIKitClassname)('profile__credentials'),
7
+ button: (0, createUIKitClassname_1.createUIKitClassname)('profile__button'),
8
+ avatar: (0, createUIKitClassname_1.createUIKitClassname)('profile__avatar'),
9
+ user: (0, createUIKitClassname_1.createUIKitClassname)('profile__user'),
7
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/ui",
3
- "version": "4.51.0",
3
+ "version": "4.52.0",
4
4
  "browser": "./index.js",
5
5
  "main": "./node/index.js",
6
6
  "dependencies": {