@astral/ui 4.1.0 → 4.1.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.
@@ -8,6 +8,6 @@ import { Title } from './Title';
8
8
  import { useLogic } from './useLogic';
9
9
  export const PageHeader = (props) => {
10
10
  const { title, description, subheader, breadcrumbs, actions, backButton, className, } = props;
11
- const { isLoading, mobileTitleActions, isShowMobileActions } = useLogic(props);
12
- return (_jsxs(_Fragment, { children: [_jsxs(MobileTitleWrapper, { "$hasBackButton": Boolean(backButton), className: classNames(pageHeaderClassnames.pageHeaderMobileTitle), children: [_jsx(Title, { backButton: backButton, title: title, isLoading: isLoading }), mobileTitleActions && mobileTitleActions] }), _jsx(Wrapper, { className: className, children: _jsx(HeaderContent, { breadcrumbs: breadcrumbs, backButton: backButton, title: title, description: description, actions: actions, subheader: subheader, isLoading: isLoading }) }), isShowMobileActions && (_jsx(MobilePageActions, Object.assign({ className: classNames(pageHeaderClassnames.pageHeaderActions), isLoading: isLoading }, actions)))] }));
11
+ const { isLoading, mobileTitleActions, isShowMobileActions, mobileClassnames, } = useLogic(props);
12
+ return (_jsxs(_Fragment, { children: [_jsxs(MobileTitleWrapper, { className: mobileClassnames, children: [_jsx(Title, { backButton: backButton, title: title, isLoading: isLoading }), mobileTitleActions && mobileTitleActions] }), _jsx(Wrapper, { className: className, children: _jsx(HeaderContent, { breadcrumbs: breadcrumbs, backButton: backButton, title: title, description: description, actions: actions, subheader: subheader, isLoading: isLoading }) }), isShowMobileActions && (_jsx(MobilePageActions, Object.assign({ className: classNames(pageHeaderClassnames.pageHeaderActions), isLoading: isLoading }, actions)))] }));
13
13
  };
@@ -1,5 +1,7 @@
1
1
  export declare const pageHeaderClassnames: {
2
2
  pageHeaderMobileTitle: string;
3
3
  pageHeaderActions: string;
4
+ hasBackButton: string;
5
+ hasTitle: string;
4
6
  };
5
7
  export declare const PAGE_HEADER_HEIGHT_MOBILE = "48px";
@@ -2,5 +2,7 @@ import { createUIKitClassname } from '../../utils';
2
2
  export const pageHeaderClassnames = {
3
3
  pageHeaderMobileTitle: createUIKitClassname('page-header__mobile-title'),
4
4
  pageHeaderActions: createUIKitClassname('page-header__actions'),
5
+ hasBackButton: createUIKitClassname('page-header_has-back-button'),
6
+ hasTitle: createUIKitClassname('page-header_has-title'),
5
7
  };
6
8
  export const PAGE_HEADER_HEIGHT_MOBILE = '48px';
@@ -6,6 +6,4 @@ export declare const Wrapper: import("@emotion/styled").StyledComponent<{
6
6
  export declare const MobileTitleWrapper: import("@emotion/styled").StyledComponent<{
7
7
  theme?: import("@emotion/react").Theme | undefined;
8
8
  as?: import("react").ElementType<any> | undefined;
9
- } & {
10
- $hasBackButton: boolean;
11
9
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -1,5 +1,5 @@
1
1
  import { styled } from '../../styles';
2
- import { PAGE_HEADER_HEIGHT_MOBILE } from './constants';
2
+ import { PAGE_HEADER_HEIGHT_MOBILE, pageHeaderClassnames } from './constants';
3
3
  export const Wrapper = styled.header `
4
4
  display: grid;
5
5
  grid-column: 1 / -1;
@@ -19,24 +19,29 @@ export const Wrapper = styled.header `
19
19
  background-color: ${({ theme }) => theme.palette.background.default};
20
20
  }
21
21
  `;
22
- export const MobileTitleWrapper = styled('div', {
23
- shouldForwardProp: (prop) => !['$hasBackButton'].includes(prop),
24
- }) `
22
+ export const MobileTitleWrapper = styled.div `
25
23
  display: none;
26
24
 
27
25
  ${({ theme }) => theme.breakpoints.down('sm')} {
28
26
  position: sticky;
29
27
  z-index: ${({ theme }) => theme.zIndex.fab};
30
28
  top: 0;
31
-
32
- display: flex;
29
+
33
30
  align-items: center;
34
31
  order: 1;
35
-
36
- height: ${PAGE_HEADER_HEIGHT_MOBILE};
37
- min-height: ${PAGE_HEADER_HEIGHT_MOBILE};
38
- padding: ${({ theme, $hasBackButton }) => $hasBackButton ? theme.spacing(0, 4, 0, 1) : theme.spacing(4)};
39
-
32
+
40
33
  background-color: ${({ theme }) => theme.palette.background.default};
34
+
35
+ &.${pageHeaderClassnames.hasTitle} {
36
+ display: flex;
37
+
38
+ height: ${PAGE_HEADER_HEIGHT_MOBILE};
39
+ min-height: ${PAGE_HEADER_HEIGHT_MOBILE};
40
+ padding: ${({ theme }) => theme.spacing(4)};
41
+ }
42
+
43
+ &.${pageHeaderClassnames.hasBackButton} {
44
+ padding: ${({ theme }) => theme.spacing(0, 4, 0, 1)};
45
+ }
41
46
  }
42
47
  `;
@@ -1,9 +1,10 @@
1
1
  import { type ElementType } from 'react';
2
2
  import type { PageHeaderProps } from '../types';
3
3
  type UseLogicParams<TMainActionComponent extends ElementType = ElementType, TSecondaryActionComponent extends ElementType = ElementType, TBackButtonComponent extends ElementType = ElementType> = PageHeaderProps<TMainActionComponent, TSecondaryActionComponent, TBackButtonComponent>;
4
- export declare const useLogic: <TMainActionComponent extends ElementType = ElementType, TSecondaryActionComponent extends ElementType = ElementType, TBackButtonComponent extends ElementType = ElementType>({ shouldUpdateDocumentTitle, title, actions, htmlTitle, }: UseLogicParams<TMainActionComponent, TSecondaryActionComponent, TBackButtonComponent>) => {
4
+ export declare const useLogic: <TMainActionComponent extends ElementType = ElementType, TSecondaryActionComponent extends ElementType = ElementType, TBackButtonComponent extends ElementType = ElementType>({ shouldUpdateDocumentTitle, title, actions, htmlTitle, backButton, }: UseLogicParams<TMainActionComponent, TSecondaryActionComponent, TBackButtonComponent>) => {
5
5
  isShowMobileActions: boolean | undefined;
6
6
  isLoading: boolean | undefined;
7
7
  mobileTitleActions: import("react").ReactNode;
8
+ mobileClassnames: string;
8
9
  };
9
10
  export {};
@@ -1,10 +1,21 @@
1
- import { useContext } from 'react';
1
+ import { useContext, useMemo } from 'react';
2
+ import { classNames } from '../../../utils';
2
3
  import { PageContext } from '../../PageContext';
4
+ import { pageHeaderClassnames } from '../constants';
3
5
  import { usePageTitle } from '../hooks';
4
- export const useLogic = ({ shouldUpdateDocumentTitle, title, actions, htmlTitle, }) => {
6
+ export const useLogic = ({ shouldUpdateDocumentTitle, title, actions, htmlTitle, backButton, }) => {
5
7
  //Переопределение Html title на title из параметров
6
8
  usePageTitle({ shouldUpdateDocumentTitle, htmlTitle, title });
7
9
  const { mobileTitleActions, isLoading } = useContext(PageContext);
8
10
  const isShowMobileActions = actions && !mobileTitleActions;
9
- return { isShowMobileActions, isLoading, mobileTitleActions };
11
+ const mobileClassnames = useMemo(() => classNames(pageHeaderClassnames.pageHeaderMobileTitle, {
12
+ [pageHeaderClassnames.hasTitle]: Boolean(title) || isLoading,
13
+ [pageHeaderClassnames.hasBackButton]: Boolean(backButton),
14
+ }), [title, backButton, isLoading]);
15
+ return {
16
+ isShowMobileActions,
17
+ isLoading,
18
+ mobileTitleActions,
19
+ mobileClassnames,
20
+ };
10
21
  };
@@ -11,7 +11,7 @@ const Title_1 = require("./Title");
11
11
  const useLogic_1 = require("./useLogic");
12
12
  const PageHeader = (props) => {
13
13
  const { title, description, subheader, breadcrumbs, actions, backButton, className, } = props;
14
- const { isLoading, mobileTitleActions, isShowMobileActions } = (0, useLogic_1.useLogic)(props);
15
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(styles_1.MobileTitleWrapper, { "$hasBackButton": Boolean(backButton), className: (0, utils_1.classNames)(constants_1.pageHeaderClassnames.pageHeaderMobileTitle), children: [(0, jsx_runtime_1.jsx)(Title_1.Title, { backButton: backButton, title: title, isLoading: isLoading }), mobileTitleActions && mobileTitleActions] }), (0, jsx_runtime_1.jsx)(styles_1.Wrapper, { className: className, children: (0, jsx_runtime_1.jsx)(HeaderContent_1.HeaderContent, { breadcrumbs: breadcrumbs, backButton: backButton, title: title, description: description, actions: actions, subheader: subheader, isLoading: isLoading }) }), isShowMobileActions && ((0, jsx_runtime_1.jsx)(MobilePageActions_1.MobilePageActions, Object.assign({ className: (0, utils_1.classNames)(constants_1.pageHeaderClassnames.pageHeaderActions), isLoading: isLoading }, actions)))] }));
14
+ const { isLoading, mobileTitleActions, isShowMobileActions, mobileClassnames, } = (0, useLogic_1.useLogic)(props);
15
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(styles_1.MobileTitleWrapper, { className: mobileClassnames, children: [(0, jsx_runtime_1.jsx)(Title_1.Title, { backButton: backButton, title: title, isLoading: isLoading }), mobileTitleActions && mobileTitleActions] }), (0, jsx_runtime_1.jsx)(styles_1.Wrapper, { className: className, children: (0, jsx_runtime_1.jsx)(HeaderContent_1.HeaderContent, { breadcrumbs: breadcrumbs, backButton: backButton, title: title, description: description, actions: actions, subheader: subheader, isLoading: isLoading }) }), isShowMobileActions && ((0, jsx_runtime_1.jsx)(MobilePageActions_1.MobilePageActions, Object.assign({ className: (0, utils_1.classNames)(constants_1.pageHeaderClassnames.pageHeaderActions), isLoading: isLoading }, actions)))] }));
16
16
  };
17
17
  exports.PageHeader = PageHeader;
@@ -1,5 +1,7 @@
1
1
  export declare const pageHeaderClassnames: {
2
2
  pageHeaderMobileTitle: string;
3
3
  pageHeaderActions: string;
4
+ hasBackButton: string;
5
+ hasTitle: string;
4
6
  };
5
7
  export declare const PAGE_HEADER_HEIGHT_MOBILE = "48px";
@@ -5,5 +5,7 @@ const utils_1 = require("../../utils");
5
5
  exports.pageHeaderClassnames = {
6
6
  pageHeaderMobileTitle: (0, utils_1.createUIKitClassname)('page-header__mobile-title'),
7
7
  pageHeaderActions: (0, utils_1.createUIKitClassname)('page-header__actions'),
8
+ hasBackButton: (0, utils_1.createUIKitClassname)('page-header_has-back-button'),
9
+ hasTitle: (0, utils_1.createUIKitClassname)('page-header_has-title'),
8
10
  };
9
11
  exports.PAGE_HEADER_HEIGHT_MOBILE = '48px';
@@ -6,6 +6,4 @@ export declare const Wrapper: import("@emotion/styled").StyledComponent<{
6
6
  export declare const MobileTitleWrapper: import("@emotion/styled").StyledComponent<{
7
7
  theme?: import("@emotion/react").Theme | undefined;
8
8
  as?: import("react").ElementType<any> | undefined;
9
- } & {
10
- $hasBackButton: boolean;
11
9
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -22,24 +22,29 @@ exports.Wrapper = styles_1.styled.header `
22
22
  background-color: ${({ theme }) => theme.palette.background.default};
23
23
  }
24
24
  `;
25
- exports.MobileTitleWrapper = (0, styles_1.styled)('div', {
26
- shouldForwardProp: (prop) => !['$hasBackButton'].includes(prop),
27
- }) `
25
+ exports.MobileTitleWrapper = styles_1.styled.div `
28
26
  display: none;
29
27
 
30
28
  ${({ theme }) => theme.breakpoints.down('sm')} {
31
29
  position: sticky;
32
30
  z-index: ${({ theme }) => theme.zIndex.fab};
33
31
  top: 0;
34
-
35
- display: flex;
32
+
36
33
  align-items: center;
37
34
  order: 1;
38
-
39
- height: ${constants_1.PAGE_HEADER_HEIGHT_MOBILE};
40
- min-height: ${constants_1.PAGE_HEADER_HEIGHT_MOBILE};
41
- padding: ${({ theme, $hasBackButton }) => $hasBackButton ? theme.spacing(0, 4, 0, 1) : theme.spacing(4)};
42
-
35
+
43
36
  background-color: ${({ theme }) => theme.palette.background.default};
37
+
38
+ &.${constants_1.pageHeaderClassnames.hasTitle} {
39
+ display: flex;
40
+
41
+ height: ${constants_1.PAGE_HEADER_HEIGHT_MOBILE};
42
+ min-height: ${constants_1.PAGE_HEADER_HEIGHT_MOBILE};
43
+ padding: ${({ theme }) => theme.spacing(4)};
44
+ }
45
+
46
+ &.${constants_1.pageHeaderClassnames.hasBackButton} {
47
+ padding: ${({ theme }) => theme.spacing(0, 4, 0, 1)};
48
+ }
44
49
  }
45
50
  `;
@@ -1,9 +1,10 @@
1
1
  import { type ElementType } from 'react';
2
2
  import type { PageHeaderProps } from '../types';
3
3
  type UseLogicParams<TMainActionComponent extends ElementType = ElementType, TSecondaryActionComponent extends ElementType = ElementType, TBackButtonComponent extends ElementType = ElementType> = PageHeaderProps<TMainActionComponent, TSecondaryActionComponent, TBackButtonComponent>;
4
- export declare const useLogic: <TMainActionComponent extends ElementType = ElementType, TSecondaryActionComponent extends ElementType = ElementType, TBackButtonComponent extends ElementType = ElementType>({ shouldUpdateDocumentTitle, title, actions, htmlTitle, }: UseLogicParams<TMainActionComponent, TSecondaryActionComponent, TBackButtonComponent>) => {
4
+ export declare const useLogic: <TMainActionComponent extends ElementType = ElementType, TSecondaryActionComponent extends ElementType = ElementType, TBackButtonComponent extends ElementType = ElementType>({ shouldUpdateDocumentTitle, title, actions, htmlTitle, backButton, }: UseLogicParams<TMainActionComponent, TSecondaryActionComponent, TBackButtonComponent>) => {
5
5
  isShowMobileActions: boolean | undefined;
6
6
  isLoading: boolean | undefined;
7
7
  mobileTitleActions: import("react").ReactNode;
8
+ mobileClassnames: string;
8
9
  };
9
10
  export {};
@@ -2,13 +2,24 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useLogic = void 0;
4
4
  const react_1 = require("react");
5
+ const utils_1 = require("../../../utils");
5
6
  const PageContext_1 = require("../../PageContext");
7
+ const constants_1 = require("../constants");
6
8
  const hooks_1 = require("../hooks");
7
- const useLogic = ({ shouldUpdateDocumentTitle, title, actions, htmlTitle, }) => {
9
+ const useLogic = ({ shouldUpdateDocumentTitle, title, actions, htmlTitle, backButton, }) => {
8
10
  //Переопределение Html title на title из параметров
9
11
  (0, hooks_1.usePageTitle)({ shouldUpdateDocumentTitle, htmlTitle, title });
10
12
  const { mobileTitleActions, isLoading } = (0, react_1.useContext)(PageContext_1.PageContext);
11
13
  const isShowMobileActions = actions && !mobileTitleActions;
12
- return { isShowMobileActions, isLoading, mobileTitleActions };
14
+ const mobileClassnames = (0, react_1.useMemo)(() => (0, utils_1.classNames)(constants_1.pageHeaderClassnames.pageHeaderMobileTitle, {
15
+ [constants_1.pageHeaderClassnames.hasTitle]: Boolean(title) || isLoading,
16
+ [constants_1.pageHeaderClassnames.hasBackButton]: Boolean(backButton),
17
+ }), [title, backButton, isLoading]);
18
+ return {
19
+ isShowMobileActions,
20
+ isLoading,
21
+ mobileTitleActions,
22
+ mobileClassnames,
23
+ };
13
24
  };
14
25
  exports.useLogic = useLogic;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/ui",
3
- "version": "4.1.0",
3
+ "version": "4.1.1",
4
4
  "browser": "./index.js",
5
5
  "main": "./node/index.js",
6
6
  "dependencies": {