@astral/ui 4.76.1 → 4.76.3

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.
@@ -1,18 +1,2 @@
1
- import { type BadgeProps as MuiBadgeProps } from '@mui/material/Badge/Badge';
2
- import { type WithoutEmotionSpecific } from '../types/WithoutEmotionSpecific';
3
- import { type BadgeColor, type BadgeVariantsColor } from './types';
4
- export type BadgeProps = Omit<WithoutEmotionSpecific<MuiBadgeProps>, 'color'> & {
5
- /**
6
- * Цвет фона
7
- */
8
- color: BadgeColor;
9
- /**
10
- * Наличие белой рамки
11
- */
12
- withBorder?: boolean;
13
- /**
14
- * Группа цвета
15
- */
16
- variantColor?: BadgeVariantsColor;
17
- };
18
- export declare const Badge: ({ children, color, max, withBorder, variantColor, ...props }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
1
+ import { type BadgeProps } from './types';
2
+ export declare const Badge: ({ children, color, max, withBorder, variantColor, classes, className, ...props }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,3 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { classNames } from '../utils/classNames';
3
+ import { badgeClassnames } from './constants';
2
4
  import { StyledBadge } from './styles';
3
- export const Badge = ({ children, color, max = 99, withBorder = true, variantColor = 'contained', ...props }) => (_jsx(StyledBadge, { "$customColor": color, max: max, "$withBorder": withBorder, "$variantColor": variantColor, ...props, children: children }));
5
+ import { useLogic } from './useLogic';
6
+ export const Badge = ({ children, color, max = 99, withBorder = true, variantColor = 'contained', classes, className, ...props }) => {
7
+ const { badgeClasses } = useLogic({ classes });
8
+ return (_jsx(StyledBadge, { "$customColor": color, max: max, "$withBorder": withBorder, "$variantColor": variantColor, classes: badgeClasses, className: classNames(badgeClassnames.root, className), ...props, children: children }));
9
+ };
@@ -0,0 +1,6 @@
1
+ export declare const badgeClassnames: {
2
+ root: string;
3
+ content: string;
4
+ dot: string;
5
+ disableAutoWidth: string;
6
+ };
@@ -0,0 +1,7 @@
1
+ import { createUIKitClassname } from '../utils/createUIKitClassname';
2
+ export const badgeClassnames = {
3
+ root: createUIKitClassname('badge'),
4
+ content: createUIKitClassname('badge__content'),
5
+ dot: createUIKitClassname('badge__dot'),
6
+ disableAutoWidth: createUIKitClassname('badge__disable-auto-width'),
7
+ };
@@ -1,5 +1,6 @@
1
1
  import Badge from '@mui/material/Badge';
2
2
  import { styled } from '../styled';
3
+ import { badgeClassnames } from './constants';
3
4
  const getBgColor = ({ $customColor, theme, $variantColor, }) => {
4
5
  const colors = {
5
6
  contained: {
@@ -46,7 +47,13 @@ const getTextColor = ({ $customColor, theme, $variantColor, }) => {
46
47
  export const StyledBadge = styled(Badge, {
47
48
  shouldForwardProp: (prop) => !['$customColor', '$withBorder', '$variantColor'].includes(prop),
48
49
  }) `
49
- .MuiBadge-badge {
50
+
51
+ /* Элемент внутри Badge будет растягиваться на всю ширину Badge */
52
+ & > * {
53
+ flex-grow: 1;
54
+ }
55
+
56
+ .${badgeClassnames.content} {
50
57
  cursor: default;
51
58
  user-select: none;
52
59
 
@@ -75,7 +82,7 @@ export const StyledBadge = styled(Badge, {
75
82
  }
76
83
  }
77
84
 
78
- .MuiBadge-dot {
85
+ .${badgeClassnames.dot} {
79
86
  width: 8px;
80
87
  min-width: unset;
81
88
  height: 8px;
@@ -1,2 +1,18 @@
1
+ import { type BadgeProps as MuiBadgeProps } from '@mui/material/Badge/Badge';
2
+ import { type WithoutEmotionSpecific } from '../types/WithoutEmotionSpecific';
1
3
  export type BadgeColor = 'primary' | 'grey' | 'white' | 'warning' | 'error' | 'success' | 'transparent';
2
4
  export type BadgeVariantsColor = 'contained' | 'light';
5
+ export type BadgeProps = Omit<WithoutEmotionSpecific<MuiBadgeProps>, 'color'> & {
6
+ /**
7
+ * Цвет фона
8
+ */
9
+ color: BadgeColor;
10
+ /**
11
+ * Наличие белой рамки
12
+ */
13
+ withBorder?: boolean;
14
+ /**
15
+ * Группа цвета
16
+ */
17
+ variantColor?: BadgeVariantsColor;
18
+ };
@@ -0,0 +1 @@
1
+ export * from './useLogic';
@@ -0,0 +1 @@
1
+ export * from './useLogic';
@@ -0,0 +1,32 @@
1
+ import { type BadgeProps } from '../types';
2
+ type UseLogicParams = Pick<BadgeProps, 'classes'>;
3
+ export declare const useLogic: ({ classes }: UseLogicParams) => {
4
+ badgeClasses: {
5
+ badge: string;
6
+ dot: string;
7
+ root?: string | undefined;
8
+ standard?: string | undefined;
9
+ anchorOriginTopRight?: string | undefined;
10
+ anchorOriginBottomRight?: string | undefined;
11
+ anchorOriginTopLeft?: string | undefined;
12
+ anchorOriginBottomLeft?: string | undefined;
13
+ invisible?: string | undefined;
14
+ colorPrimary?: string | undefined;
15
+ colorSecondary?: string | undefined;
16
+ colorError?: string | undefined;
17
+ colorInfo?: string | undefined;
18
+ colorSuccess?: string | undefined;
19
+ colorWarning?: string | undefined;
20
+ anchorOriginTopRightRectangular?: string | undefined;
21
+ anchorOriginBottomRightRectangular?: string | undefined;
22
+ anchorOriginTopLeftRectangular?: string | undefined;
23
+ anchorOriginBottomLeftRectangular?: string | undefined;
24
+ anchorOriginTopRightCircular?: string | undefined;
25
+ anchorOriginBottomRightCircular?: string | undefined;
26
+ anchorOriginTopLeftCircular?: string | undefined;
27
+ anchorOriginBottomLeftCircular?: string | undefined;
28
+ overlapRectangular?: string | undefined;
29
+ overlapCircular?: string | undefined;
30
+ };
31
+ };
32
+ export {};
@@ -0,0 +1,15 @@
1
+ import { useMemo } from 'react';
2
+ import { badgeClassnames } from '../constants';
3
+ export const useLogic = ({ classes }) => {
4
+ const { badge = '', dot = '', ...restClasses } = classes || {};
5
+ const badgeClasses = useMemo(() => {
6
+ return {
7
+ ...restClasses,
8
+ badge: `${badgeClassnames.content} ${badge}`,
9
+ dot: `${badgeClassnames.dot} ${dot}`,
10
+ };
11
+ }, [classes]);
12
+ return {
13
+ badgeClasses,
14
+ };
15
+ };
@@ -1,18 +1,2 @@
1
- import { type BadgeProps as MuiBadgeProps } from '@mui/material/Badge/Badge';
2
- import { type WithoutEmotionSpecific } from '../types/WithoutEmotionSpecific';
3
- import { type BadgeColor, type BadgeVariantsColor } from './types';
4
- export type BadgeProps = Omit<WithoutEmotionSpecific<MuiBadgeProps>, 'color'> & {
5
- /**
6
- * Цвет фона
7
- */
8
- color: BadgeColor;
9
- /**
10
- * Наличие белой рамки
11
- */
12
- withBorder?: boolean;
13
- /**
14
- * Группа цвета
15
- */
16
- variantColor?: BadgeVariantsColor;
17
- };
18
- export declare const Badge: ({ children, color, max, withBorder, variantColor, ...props }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
1
+ import { type BadgeProps } from './types';
2
+ export declare const Badge: ({ children, color, max, withBorder, variantColor, classes, className, ...props }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
@@ -2,6 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Badge = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const classNames_1 = require("../utils/classNames");
6
+ const constants_1 = require("./constants");
5
7
  const styles_1 = require("./styles");
6
- const Badge = ({ children, color, max = 99, withBorder = true, variantColor = 'contained', ...props }) => ((0, jsx_runtime_1.jsx)(styles_1.StyledBadge, { "$customColor": color, max: max, "$withBorder": withBorder, "$variantColor": variantColor, ...props, children: children }));
8
+ const useLogic_1 = require("./useLogic");
9
+ const Badge = ({ children, color, max = 99, withBorder = true, variantColor = 'contained', classes, className, ...props }) => {
10
+ const { badgeClasses } = (0, useLogic_1.useLogic)({ classes });
11
+ return ((0, jsx_runtime_1.jsx)(styles_1.StyledBadge, { "$customColor": color, max: max, "$withBorder": withBorder, "$variantColor": variantColor, classes: badgeClasses, className: (0, classNames_1.classNames)(constants_1.badgeClassnames.root, className), ...props, children: children }));
12
+ };
7
13
  exports.Badge = Badge;
@@ -0,0 +1,6 @@
1
+ export declare const badgeClassnames: {
2
+ root: string;
3
+ content: string;
4
+ dot: string;
5
+ disableAutoWidth: string;
6
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.badgeClassnames = void 0;
4
+ const createUIKitClassname_1 = require("../utils/createUIKitClassname");
5
+ exports.badgeClassnames = {
6
+ root: (0, createUIKitClassname_1.createUIKitClassname)('badge'),
7
+ content: (0, createUIKitClassname_1.createUIKitClassname)('badge__content'),
8
+ dot: (0, createUIKitClassname_1.createUIKitClassname)('badge__dot'),
9
+ disableAutoWidth: (0, createUIKitClassname_1.createUIKitClassname)('badge__disable-auto-width'),
10
+ };
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.StyledBadge = void 0;
7
7
  const Badge_1 = __importDefault(require("@mui/material/Badge"));
8
8
  const styled_1 = require("../styled");
9
+ const constants_1 = require("./constants");
9
10
  const getBgColor = ({ $customColor, theme, $variantColor, }) => {
10
11
  const colors = {
11
12
  contained: {
@@ -52,7 +53,13 @@ const getTextColor = ({ $customColor, theme, $variantColor, }) => {
52
53
  exports.StyledBadge = (0, styled_1.styled)(Badge_1.default, {
53
54
  shouldForwardProp: (prop) => !['$customColor', '$withBorder', '$variantColor'].includes(prop),
54
55
  }) `
55
- .MuiBadge-badge {
56
+
57
+ /* Элемент внутри Badge будет растягиваться на всю ширину Badge */
58
+ & > * {
59
+ flex-grow: 1;
60
+ }
61
+
62
+ .${constants_1.badgeClassnames.content} {
56
63
  cursor: default;
57
64
  user-select: none;
58
65
 
@@ -81,7 +88,7 @@ exports.StyledBadge = (0, styled_1.styled)(Badge_1.default, {
81
88
  }
82
89
  }
83
90
 
84
- .MuiBadge-dot {
91
+ .${constants_1.badgeClassnames.dot} {
85
92
  width: 8px;
86
93
  min-width: unset;
87
94
  height: 8px;
@@ -1,2 +1,18 @@
1
+ import { type BadgeProps as MuiBadgeProps } from '@mui/material/Badge/Badge';
2
+ import { type WithoutEmotionSpecific } from '../types/WithoutEmotionSpecific';
1
3
  export type BadgeColor = 'primary' | 'grey' | 'white' | 'warning' | 'error' | 'success' | 'transparent';
2
4
  export type BadgeVariantsColor = 'contained' | 'light';
5
+ export type BadgeProps = Omit<WithoutEmotionSpecific<MuiBadgeProps>, 'color'> & {
6
+ /**
7
+ * Цвет фона
8
+ */
9
+ color: BadgeColor;
10
+ /**
11
+ * Наличие белой рамки
12
+ */
13
+ withBorder?: boolean;
14
+ /**
15
+ * Группа цвета
16
+ */
17
+ variantColor?: BadgeVariantsColor;
18
+ };
@@ -0,0 +1 @@
1
+ export * from './useLogic';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./useLogic"), exports);
@@ -0,0 +1,32 @@
1
+ import { type BadgeProps } from '../types';
2
+ type UseLogicParams = Pick<BadgeProps, 'classes'>;
3
+ export declare const useLogic: ({ classes }: UseLogicParams) => {
4
+ badgeClasses: {
5
+ badge: string;
6
+ dot: string;
7
+ root?: string | undefined;
8
+ standard?: string | undefined;
9
+ anchorOriginTopRight?: string | undefined;
10
+ anchorOriginBottomRight?: string | undefined;
11
+ anchorOriginTopLeft?: string | undefined;
12
+ anchorOriginBottomLeft?: string | undefined;
13
+ invisible?: string | undefined;
14
+ colorPrimary?: string | undefined;
15
+ colorSecondary?: string | undefined;
16
+ colorError?: string | undefined;
17
+ colorInfo?: string | undefined;
18
+ colorSuccess?: string | undefined;
19
+ colorWarning?: string | undefined;
20
+ anchorOriginTopRightRectangular?: string | undefined;
21
+ anchorOriginBottomRightRectangular?: string | undefined;
22
+ anchorOriginTopLeftRectangular?: string | undefined;
23
+ anchorOriginBottomLeftRectangular?: string | undefined;
24
+ anchorOriginTopRightCircular?: string | undefined;
25
+ anchorOriginBottomRightCircular?: string | undefined;
26
+ anchorOriginTopLeftCircular?: string | undefined;
27
+ anchorOriginBottomLeftCircular?: string | undefined;
28
+ overlapRectangular?: string | undefined;
29
+ overlapCircular?: string | undefined;
30
+ };
31
+ };
32
+ export {};
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useLogic = void 0;
4
+ const react_1 = require("react");
5
+ const constants_1 = require("../constants");
6
+ const useLogic = ({ classes }) => {
7
+ const { badge = '', dot = '', ...restClasses } = classes || {};
8
+ const badgeClasses = (0, react_1.useMemo)(() => {
9
+ return {
10
+ ...restClasses,
11
+ badge: `${constants_1.badgeClassnames.content} ${badge}`,
12
+ dot: `${constants_1.badgeClassnames.dot} ${dot}`,
13
+ };
14
+ }, [classes]);
15
+ return {
16
+ badgeClasses,
17
+ };
18
+ };
19
+ exports.useLogic = useLogic;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/ui",
3
- "version": "4.76.1",
3
+ "version": "4.76.3",
4
4
  "browser": "./index.js",
5
5
  "main": "./node/index.js",
6
6
  "dependencies": {