@astral/ui 4.0.1 → 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.
Files changed (27) hide show
  1. package/components/PageLayout/PageHeader/PageHeader.js +2 -2
  2. package/components/PageLayout/PageHeader/constants.d.ts +2 -0
  3. package/components/PageLayout/PageHeader/constants.js +2 -0
  4. package/components/PageLayout/PageHeader/styles.d.ts +0 -2
  5. package/components/PageLayout/PageHeader/styles.js +16 -11
  6. package/components/PageLayout/PageHeader/useLogic/useLogic.d.ts +2 -1
  7. package/components/PageLayout/PageHeader/useLogic/useLogic.js +14 -3
  8. package/components/Tag/Tag.js +8 -3
  9. package/components/Tag/constants.d.ts +9 -0
  10. package/components/Tag/constants.js +9 -0
  11. package/components/Tag/styles.js +29 -2
  12. package/components/Tag/useLogic/useLogic.d.ts +3 -2
  13. package/components/Tag/useLogic/useLogic.js +15 -2
  14. package/node/components/PageLayout/PageHeader/PageHeader.js +2 -2
  15. package/node/components/PageLayout/PageHeader/constants.d.ts +2 -0
  16. package/node/components/PageLayout/PageHeader/constants.js +2 -0
  17. package/node/components/PageLayout/PageHeader/styles.d.ts +0 -2
  18. package/node/components/PageLayout/PageHeader/styles.js +15 -10
  19. package/node/components/PageLayout/PageHeader/useLogic/useLogic.d.ts +2 -1
  20. package/node/components/PageLayout/PageHeader/useLogic/useLogic.js +13 -2
  21. package/node/components/Tag/Tag.js +8 -3
  22. package/node/components/Tag/constants.d.ts +9 -0
  23. package/node/components/Tag/constants.js +9 -0
  24. package/node/components/Tag/styles.js +29 -2
  25. package/node/components/Tag/useLogic/useLogic.d.ts +3 -2
  26. package/node/components/Tag/useLogic/useLogic.js +15 -2
  27. package/package.json +1 -1
@@ -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
  };
@@ -13,14 +13,19 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { forwardRef } from 'react';
14
14
  import { CrossSmOutlineSm } from '../../icons';
15
15
  import { Typography } from '../Typography';
16
- import { classNames } from '../utils';
17
16
  import { tagClassnames } from './constants';
18
17
  import { getBadgeColor, IconWrapper, Label, LabelContainer, LabelWrapper, StyledIconButton, Wrapper, } from './styles';
19
18
  import { TagContextProvider } from './TagContext';
20
19
  import { useLogic } from './useLogic';
21
20
  export const Tag = forwardRef((_a, ref) => {
22
21
  var { onDelete, color = 'grey', variant = 'contained', size = 'small', label, startAddon, endAddon, disabled, icon, className } = _a, restProps = __rest(_a, ["onDelete", "color", "variant", "size", "label", "startAddon", "endAddon", "disabled", "icon", "className"]);
23
- const { handleDelete } = useLogic({ onDelete });
22
+ const { handleDelete, classnames } = useLogic({
23
+ onDelete,
24
+ size,
25
+ variant,
26
+ disabled,
27
+ className,
28
+ });
24
29
  const labelContent = (_jsxs(LabelContainer, { container: true, component: "span", spacing: 1, className: tagClassnames.label, "$variant": variant, children: [startAddon === null || startAddon === void 0 ? void 0 : startAddon({
25
30
  color: getBadgeColor({
26
31
  tagColor: color,
@@ -30,5 +35,5 @@ export const Tag = forwardRef((_a, ref) => {
30
35
  tagColor: color,
31
36
  }),
32
37
  })] }));
33
- return (_jsx(TagContextProvider, { variant: variant, children: _jsxs(Wrapper, Object.assign({ ref: ref, "$size": size, "$color": color, "$variant": variant, "$isDisabled": disabled, "$isRemovable": Boolean(onDelete), className: classNames(className, tagClassnames.root) }, restProps, { children: [icon && (_jsx(IconWrapper, { className: tagClassnames.icon, children: icon })), _jsx(Typography, { variant: "body1", component: Label, children: labelContent }), onDelete && !disabled && (_jsx(StyledIconButton, { onClick: handleDelete, "$color": color, "$variant": variant, "$size": size, "aria-label": "\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u044D\u043B\u0435\u043C\u0435\u043D\u0442", children: _jsx(CrossSmOutlineSm, {}) }))] })) }));
38
+ return (_jsx(TagContextProvider, { variant: variant, children: _jsxs(Wrapper, Object.assign({ ref: ref, "$size": size, "$color": color, "$variant": variant, "$isDisabled": disabled, "$isRemovable": Boolean(onDelete), className: classnames }, restProps, { children: [icon && (_jsx(IconWrapper, { className: tagClassnames.icon, children: icon })), _jsx(Typography, { variant: "body1", component: Label, children: labelContent }), onDelete && !disabled && (_jsx(StyledIconButton, { onClick: handleDelete, "$color": color, "$variant": variant, "$size": size, "aria-label": "\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u044D\u043B\u0435\u043C\u0435\u043D\u0442", children: _jsx(CrossSmOutlineSm, {}) }))] })) }));
34
39
  });
@@ -3,4 +3,13 @@ export declare const tagClassnames: {
3
3
  root: string;
4
4
  icon: string;
5
5
  badge: string;
6
+ variantText: string;
7
+ variantContained: string;
8
+ variantLight: string;
9
+ sizeSmall: string;
10
+ sizeMedium: string;
11
+ sizeLarge: string;
12
+ variantTextLarge: string;
13
+ removable: string;
14
+ disabled: string;
6
15
  };
@@ -4,4 +4,13 @@ export const tagClassnames = {
4
4
  root: createUIKitClassname('tag'),
5
5
  icon: createUIKitClassname('tag__icon'),
6
6
  badge: createUIKitClassname('tag__badge'),
7
+ variantText: createUIKitClassname('tag_variant_text'),
8
+ variantContained: createUIKitClassname('tag_variant_contained'),
9
+ variantLight: createUIKitClassname('tag_variant_light'),
10
+ sizeSmall: createUIKitClassname('tag_size_small'),
11
+ sizeMedium: createUIKitClassname('tag_size_medium'),
12
+ sizeLarge: createUIKitClassname('tag_size_large'),
13
+ variantTextLarge: createUIKitClassname('tag_variant_text-large'),
14
+ removable: createUIKitClassname('tag_removable'),
15
+ disabled: createUIKitClassname('tag_disabled'),
7
16
  };
@@ -212,9 +212,9 @@ export const Wrapper = styled.div `
212
212
 
213
213
  max-width: 100%;
214
214
  height: ${({ $size }) => HEIGHTS[$size]};
215
- padding-right: ${({ theme, $isRemovable, $isDisabled }) => $isRemovable && !$isDisabled ? theme.microSpacing(1) : theme.spacing(2)};
215
+ padding-right: ${({ theme }) => theme.spacing(2)};
216
216
  padding-left: ${({ theme }) => theme.spacing(2)};
217
-
217
+
218
218
  color: ${({ theme, $variant, $color, $isDisabled }) => getColor({
219
219
  theme,
220
220
  variant: $variant,
@@ -232,6 +232,33 @@ export const Wrapper = styled.div `
232
232
  ? `1px solid ${theme.palette.grey[400]}`
233
233
  : 'none'};
234
234
  border-radius: ${({ theme }) => theme.shape.medium};
235
+
236
+ &.${tagClassnames.sizeLarge} {
237
+ padding-right: ${({ theme }) => theme.spacing(3)};
238
+ padding-left: ${({ theme }) => theme.spacing(3)};
239
+ }
240
+
241
+ &.${tagClassnames.sizeLarge}.${tagClassnames.variantTextLarge} {
242
+ padding-right: 0;
243
+ padding-left: 0;
244
+ }
245
+
246
+ &.${tagClassnames.variantText} {
247
+ padding-right: 0;
248
+ padding-left: 0;
249
+ }
250
+
251
+ &.${tagClassnames.removable}.${tagClassnames.sizeLarge} {
252
+ padding-right: ${({ theme }) => theme.spacing(1)};
253
+ }
254
+
255
+ &.${tagClassnames.removable}:not(.${tagClassnames.sizeLarge}):not(.${tagClassnames.disabled}) {
256
+ padding-right: ${({ theme }) => theme.microSpacing(1)};
257
+ }
258
+
259
+ &.${tagClassnames.variantText}.${tagClassnames.removable} {
260
+ padding-right: 0;
261
+ }
235
262
  `;
236
263
  export const LabelWrapper = styled.span `
237
264
  overflow: hidden;
@@ -1,7 +1,8 @@
1
1
  import { type SyntheticEvent } from 'react';
2
2
  import { type TagProps } from '../types';
3
- type UseLogicParams = Pick<TagProps, 'onDelete'>;
4
- export declare const useLogic: ({ onDelete }: UseLogicParams) => {
3
+ type UseLogicParams = Pick<TagProps, 'onDelete' | 'variant' | 'size' | 'disabled' | 'className'>;
4
+ export declare const useLogic: ({ onDelete, variant, disabled, size, className, }: UseLogicParams) => {
5
5
  handleDelete: (event: SyntheticEvent) => void;
6
+ classnames: string;
6
7
  };
7
8
  export {};
@@ -1,7 +1,20 @@
1
- export const useLogic = ({ onDelete }) => {
1
+ import { useMemo } from 'react';
2
+ import { classNames } from '../../utils';
3
+ import { tagClassnames } from '../constants';
4
+ export const useLogic = ({ onDelete, variant, disabled, size, className, }) => {
2
5
  const handleDelete = (event) => {
3
6
  event.stopPropagation();
4
7
  onDelete === null || onDelete === void 0 ? void 0 : onDelete(event);
5
8
  };
6
- return { handleDelete };
9
+ const classnames = useMemo(() => classNames(tagClassnames.root, {
10
+ [tagClassnames.variantText]: variant === 'text',
11
+ [tagClassnames.variantContained]: variant === 'contained',
12
+ [tagClassnames.variantLight]: variant === 'light',
13
+ [tagClassnames.sizeSmall]: size === 'small',
14
+ [tagClassnames.sizeMedium]: size === 'medium',
15
+ [tagClassnames.sizeLarge]: size === 'large',
16
+ [tagClassnames.removable]: Boolean(onDelete),
17
+ [tagClassnames.disabled]: disabled,
18
+ }, className), [variant, size, onDelete, disabled, className]);
19
+ return { handleDelete, classnames };
7
20
  };
@@ -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;
@@ -16,14 +16,19 @@ const jsx_runtime_1 = require("react/jsx-runtime");
16
16
  const react_1 = require("react");
17
17
  const icons_1 = require("../../icons");
18
18
  const Typography_1 = require("../Typography");
19
- const utils_1 = require("../utils");
20
19
  const constants_1 = require("./constants");
21
20
  const styles_1 = require("./styles");
22
21
  const TagContext_1 = require("./TagContext");
23
22
  const useLogic_1 = require("./useLogic");
24
23
  exports.Tag = (0, react_1.forwardRef)((_a, ref) => {
25
24
  var { onDelete, color = 'grey', variant = 'contained', size = 'small', label, startAddon, endAddon, disabled, icon, className } = _a, restProps = __rest(_a, ["onDelete", "color", "variant", "size", "label", "startAddon", "endAddon", "disabled", "icon", "className"]);
26
- const { handleDelete } = (0, useLogic_1.useLogic)({ onDelete });
25
+ const { handleDelete, classnames } = (0, useLogic_1.useLogic)({
26
+ onDelete,
27
+ size,
28
+ variant,
29
+ disabled,
30
+ className,
31
+ });
27
32
  const labelContent = ((0, jsx_runtime_1.jsxs)(styles_1.LabelContainer, { container: true, component: "span", spacing: 1, className: constants_1.tagClassnames.label, "$variant": variant, children: [startAddon === null || startAddon === void 0 ? void 0 : startAddon({
28
33
  color: (0, styles_1.getBadgeColor)({
29
34
  tagColor: color,
@@ -33,5 +38,5 @@ exports.Tag = (0, react_1.forwardRef)((_a, ref) => {
33
38
  tagColor: color,
34
39
  }),
35
40
  })] }));
36
- return ((0, jsx_runtime_1.jsx)(TagContext_1.TagContextProvider, { variant: variant, children: (0, jsx_runtime_1.jsxs)(styles_1.Wrapper, Object.assign({ ref: ref, "$size": size, "$color": color, "$variant": variant, "$isDisabled": disabled, "$isRemovable": Boolean(onDelete), className: (0, utils_1.classNames)(className, constants_1.tagClassnames.root) }, restProps, { children: [icon && ((0, jsx_runtime_1.jsx)(styles_1.IconWrapper, { className: constants_1.tagClassnames.icon, children: icon })), (0, jsx_runtime_1.jsx)(Typography_1.Typography, { variant: "body1", component: styles_1.Label, children: labelContent }), onDelete && !disabled && ((0, jsx_runtime_1.jsx)(styles_1.StyledIconButton, { onClick: handleDelete, "$color": color, "$variant": variant, "$size": size, "aria-label": "\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u044D\u043B\u0435\u043C\u0435\u043D\u0442", children: (0, jsx_runtime_1.jsx)(icons_1.CrossSmOutlineSm, {}) }))] })) }));
41
+ return ((0, jsx_runtime_1.jsx)(TagContext_1.TagContextProvider, { variant: variant, children: (0, jsx_runtime_1.jsxs)(styles_1.Wrapper, Object.assign({ ref: ref, "$size": size, "$color": color, "$variant": variant, "$isDisabled": disabled, "$isRemovable": Boolean(onDelete), className: classnames }, restProps, { children: [icon && ((0, jsx_runtime_1.jsx)(styles_1.IconWrapper, { className: constants_1.tagClassnames.icon, children: icon })), (0, jsx_runtime_1.jsx)(Typography_1.Typography, { variant: "body1", component: styles_1.Label, children: labelContent }), onDelete && !disabled && ((0, jsx_runtime_1.jsx)(styles_1.StyledIconButton, { onClick: handleDelete, "$color": color, "$variant": variant, "$size": size, "aria-label": "\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u044D\u043B\u0435\u043C\u0435\u043D\u0442", children: (0, jsx_runtime_1.jsx)(icons_1.CrossSmOutlineSm, {}) }))] })) }));
37
42
  });
@@ -3,4 +3,13 @@ export declare const tagClassnames: {
3
3
  root: string;
4
4
  icon: string;
5
5
  badge: string;
6
+ variantText: string;
7
+ variantContained: string;
8
+ variantLight: string;
9
+ sizeSmall: string;
10
+ sizeMedium: string;
11
+ sizeLarge: string;
12
+ variantTextLarge: string;
13
+ removable: string;
14
+ disabled: string;
6
15
  };
@@ -7,4 +7,13 @@ exports.tagClassnames = {
7
7
  root: (0, utils_1.createUIKitClassname)('tag'),
8
8
  icon: (0, utils_1.createUIKitClassname)('tag__icon'),
9
9
  badge: (0, utils_1.createUIKitClassname)('tag__badge'),
10
+ variantText: (0, utils_1.createUIKitClassname)('tag_variant_text'),
11
+ variantContained: (0, utils_1.createUIKitClassname)('tag_variant_contained'),
12
+ variantLight: (0, utils_1.createUIKitClassname)('tag_variant_light'),
13
+ sizeSmall: (0, utils_1.createUIKitClassname)('tag_size_small'),
14
+ sizeMedium: (0, utils_1.createUIKitClassname)('tag_size_medium'),
15
+ sizeLarge: (0, utils_1.createUIKitClassname)('tag_size_large'),
16
+ variantTextLarge: (0, utils_1.createUIKitClassname)('tag_variant_text-large'),
17
+ removable: (0, utils_1.createUIKitClassname)('tag_removable'),
18
+ disabled: (0, utils_1.createUIKitClassname)('tag_disabled'),
10
19
  };
@@ -217,9 +217,9 @@ exports.Wrapper = styles_1.styled.div `
217
217
 
218
218
  max-width: 100%;
219
219
  height: ${({ $size }) => HEIGHTS[$size]};
220
- padding-right: ${({ theme, $isRemovable, $isDisabled }) => $isRemovable && !$isDisabled ? theme.microSpacing(1) : theme.spacing(2)};
220
+ padding-right: ${({ theme }) => theme.spacing(2)};
221
221
  padding-left: ${({ theme }) => theme.spacing(2)};
222
-
222
+
223
223
  color: ${({ theme, $variant, $color, $isDisabled }) => getColor({
224
224
  theme,
225
225
  variant: $variant,
@@ -237,6 +237,33 @@ exports.Wrapper = styles_1.styled.div `
237
237
  ? `1px solid ${theme.palette.grey[400]}`
238
238
  : 'none'};
239
239
  border-radius: ${({ theme }) => theme.shape.medium};
240
+
241
+ &.${constants_1.tagClassnames.sizeLarge} {
242
+ padding-right: ${({ theme }) => theme.spacing(3)};
243
+ padding-left: ${({ theme }) => theme.spacing(3)};
244
+ }
245
+
246
+ &.${constants_1.tagClassnames.sizeLarge}.${constants_1.tagClassnames.variantTextLarge} {
247
+ padding-right: 0;
248
+ padding-left: 0;
249
+ }
250
+
251
+ &.${constants_1.tagClassnames.variantText} {
252
+ padding-right: 0;
253
+ padding-left: 0;
254
+ }
255
+
256
+ &.${constants_1.tagClassnames.removable}.${constants_1.tagClassnames.sizeLarge} {
257
+ padding-right: ${({ theme }) => theme.spacing(1)};
258
+ }
259
+
260
+ &.${constants_1.tagClassnames.removable}:not(.${constants_1.tagClassnames.sizeLarge}):not(.${constants_1.tagClassnames.disabled}) {
261
+ padding-right: ${({ theme }) => theme.microSpacing(1)};
262
+ }
263
+
264
+ &.${constants_1.tagClassnames.variantText}.${constants_1.tagClassnames.removable} {
265
+ padding-right: 0;
266
+ }
240
267
  `;
241
268
  exports.LabelWrapper = styles_1.styled.span `
242
269
  overflow: hidden;
@@ -1,7 +1,8 @@
1
1
  import { type SyntheticEvent } from 'react';
2
2
  import { type TagProps } from '../types';
3
- type UseLogicParams = Pick<TagProps, 'onDelete'>;
4
- export declare const useLogic: ({ onDelete }: UseLogicParams) => {
3
+ type UseLogicParams = Pick<TagProps, 'onDelete' | 'variant' | 'size' | 'disabled' | 'className'>;
4
+ export declare const useLogic: ({ onDelete, variant, disabled, size, className, }: UseLogicParams) => {
5
5
  handleDelete: (event: SyntheticEvent) => void;
6
+ classnames: string;
6
7
  };
7
8
  export {};
@@ -1,11 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useLogic = void 0;
4
- const useLogic = ({ onDelete }) => {
4
+ const react_1 = require("react");
5
+ const utils_1 = require("../../utils");
6
+ const constants_1 = require("../constants");
7
+ const useLogic = ({ onDelete, variant, disabled, size, className, }) => {
5
8
  const handleDelete = (event) => {
6
9
  event.stopPropagation();
7
10
  onDelete === null || onDelete === void 0 ? void 0 : onDelete(event);
8
11
  };
9
- return { handleDelete };
12
+ const classnames = (0, react_1.useMemo)(() => (0, utils_1.classNames)(constants_1.tagClassnames.root, {
13
+ [constants_1.tagClassnames.variantText]: variant === 'text',
14
+ [constants_1.tagClassnames.variantContained]: variant === 'contained',
15
+ [constants_1.tagClassnames.variantLight]: variant === 'light',
16
+ [constants_1.tagClassnames.sizeSmall]: size === 'small',
17
+ [constants_1.tagClassnames.sizeMedium]: size === 'medium',
18
+ [constants_1.tagClassnames.sizeLarge]: size === 'large',
19
+ [constants_1.tagClassnames.removable]: Boolean(onDelete),
20
+ [constants_1.tagClassnames.disabled]: disabled,
21
+ }, className), [variant, size, onDelete, disabled, className]);
22
+ return { handleDelete, classnames };
10
23
  };
11
24
  exports.useLogic = useLogic;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/ui",
3
- "version": "4.0.1",
3
+ "version": "4.1.1",
4
4
  "browser": "./index.js",
5
5
  "main": "./node/index.js",
6
6
  "dependencies": {