@ozen-ui/kit 0.19.0 → 0.21.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.
- package/__inner__/cjs/components/Avatar/Avatar.css +28 -25
- package/__inner__/cjs/components/Avatar/Avatar.d.ts +3 -3
- package/__inner__/cjs/components/Avatar/Avatar.js +15 -27
- package/__inner__/cjs/components/Avatar/utils.d.ts +6 -0
- package/__inner__/cjs/components/Avatar/utils.js +26 -0
- package/__inner__/cjs/components/Button/Button.d.ts +5 -5
- package/__inner__/cjs/components/Button/Button.js +12 -3
- package/__inner__/cjs/components/Card/Card.js +1 -1
- package/__inner__/cjs/components/Grid/Grid.css +18 -0
- package/__inner__/cjs/components/Grid/Grid.d.ts +8 -0
- package/__inner__/cjs/components/Grid/Grid.js +12 -3
- package/__inner__/cjs/components/IconButton/IconButton.d.ts +5 -5
- package/__inner__/cjs/components/IconButton/IconButton.js +14 -6
- package/__inner__/cjs/components/Indicator/Indicator.css +1 -0
- package/__inner__/cjs/components/List/List.css +6 -1
- package/__inner__/cjs/components/List/components/ListItem/ListItem.css +1 -1
- package/__inner__/cjs/components/List/components/ListItemButton/ListItemButton.css +11 -11
- package/__inner__/cjs/components/List/components/ListItemButton/ListItemButton.d.ts +3 -0
- package/__inner__/cjs/components/List/components/ListItemButton/ListItemButton.js +2 -1
- package/__inner__/cjs/components/Menu/components/MenuItem/MenuItem.d.ts +0 -2
- package/__inner__/cjs/components/Menu/components/MenuItem/MenuItem.js +1 -1
- package/__inner__/cjs/components/Table/components/TableRow/TableRow.css +6 -1
- package/__inner__/cjs/components/ThemeProvider/_color/Theme_color_bBusinessDefault.css +2 -2
- package/__inner__/cjs/components/ThemeProvider/_color/Theme_color_ozenDark.css +1 -1
- package/__inner__/cjs/components/ThemeProvider/_color/Theme_color_ozenDefault.css +1 -1
- package/__inner__/cjs/hooks/useBoolean/useBoolean.d.ts +2 -3
- package/__inner__/esm/components/Avatar/Avatar.css +28 -25
- package/__inner__/esm/components/Avatar/Avatar.d.ts +3 -3
- package/__inner__/esm/components/Avatar/Avatar.js +14 -26
- package/__inner__/esm/components/Avatar/utils.d.ts +6 -0
- package/__inner__/esm/components/Avatar/utils.js +22 -0
- package/__inner__/esm/components/Button/Button.d.ts +5 -5
- package/__inner__/esm/components/Button/Button.js +12 -3
- package/__inner__/esm/components/Card/Card.js +1 -1
- package/__inner__/esm/components/Grid/Grid.css +18 -0
- package/__inner__/esm/components/Grid/Grid.d.ts +8 -0
- package/__inner__/esm/components/Grid/Grid.js +11 -2
- package/__inner__/esm/components/IconButton/IconButton.d.ts +5 -5
- package/__inner__/esm/components/IconButton/IconButton.js +14 -6
- package/__inner__/esm/components/Indicator/Indicator.css +1 -0
- package/__inner__/esm/components/List/List.css +6 -1
- package/__inner__/esm/components/List/components/ListItem/ListItem.css +1 -1
- package/__inner__/esm/components/List/components/ListItemButton/ListItemButton.css +11 -11
- package/__inner__/esm/components/List/components/ListItemButton/ListItemButton.d.ts +3 -0
- package/__inner__/esm/components/List/components/ListItemButton/ListItemButton.js +2 -1
- package/__inner__/esm/components/Menu/components/MenuItem/MenuItem.d.ts +0 -2
- package/__inner__/esm/components/Menu/components/MenuItem/MenuItem.js +2 -2
- package/__inner__/esm/components/Table/components/TableRow/TableRow.css +6 -1
- package/__inner__/esm/components/ThemeProvider/_color/Theme_color_bBusinessDefault.css +2 -2
- package/__inner__/esm/components/ThemeProvider/_color/Theme_color_ozenDark.css +1 -1
- package/__inner__/esm/components/ThemeProvider/_color/Theme_color_ozenDefault.css +1 -1
- package/__inner__/esm/hooks/useBoolean/useBoolean.d.ts +2 -3
- package/package.json +1 -1
|
@@ -4,8 +4,6 @@ import { type ListItemButtonBaseProps } from '../../../List';
|
|
|
4
4
|
import { LIST_ITEM_BUTTON_DEFAULT_TAG } from '../../../List/constants';
|
|
5
5
|
export declare const cnMenuItem: import("@bem-react/classname").ClassNameFormatter;
|
|
6
6
|
export type MenuItemBaseProps = ListItemButtonBaseProps & {
|
|
7
|
-
/** Если {true} отображает элемент меню как выбранный */
|
|
8
|
-
selected?: boolean;
|
|
9
7
|
/** Используется для вычисления лейбла выбранного элемента меню в выпадающих списках */
|
|
10
8
|
label?: string;
|
|
11
9
|
/** Используется для вычисления значения выбранного элемента меню в выпадающих списках */
|
|
@@ -20,6 +20,6 @@ exports.MenuItem = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef
|
|
|
20
20
|
(_a = innerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
21
21
|
}
|
|
22
22
|
}, [autoFocus, disabled]);
|
|
23
|
-
return (react_1.default.createElement(List_1.ListItemButton, tslib_1.__assign({ role: "menuitem", as: Tag, disabled: disabled }, other, { ref: (0, useMultiRef_1.useMultiRef)([ref, innerRef]), className: (0,
|
|
23
|
+
return (react_1.default.createElement(List_1.ListItemButton, tslib_1.__assign({ role: "menuitem", as: Tag, disabled: disabled, selected: selected }, other, { ref: (0, useMultiRef_1.useMultiRef)([ref, innerRef]), className: (0, exports.cnMenuItem)('', [className]), "data-value": value, "data-label": label }), children));
|
|
24
24
|
});
|
|
25
25
|
exports.MenuItem.displayName = 'MenuItem';
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
.
|
|
1
|
+
.TableRow {
|
|
2
|
+
transition: background-color var(--transition-slow);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.TableRow_hover:hover {
|
|
2
6
|
outline: none;
|
|
3
7
|
background-color: var(--color-background-primary-hover);
|
|
4
8
|
}
|
|
9
|
+
|
|
5
10
|
.TableRow_hover:active,
|
|
6
11
|
.TableRow_selected {
|
|
7
12
|
outline: none;
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
--color-content-primary-inverse: #fff;
|
|
30
30
|
--color-content-accent-main: #a0a0a0;
|
|
31
31
|
--color-accent-main: #181818;
|
|
32
|
-
--color-content-accent-primary: #
|
|
32
|
+
--color-content-accent-primary: #dcdcdc;
|
|
33
33
|
--color-accent-primary: #282828;
|
|
34
34
|
--color-content-accent-disabled: #606060;
|
|
35
35
|
--color-background-main: #fff;
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
--color-accent-tertiary-pressed: #686868;
|
|
125
125
|
--color-accent-disabled: #484848;
|
|
126
126
|
--color-accent-secondary-inverse: #808080;
|
|
127
|
-
--color-accent-main-inverse: #
|
|
127
|
+
--color-accent-main-inverse: #dcdcdc;
|
|
128
128
|
--color-additional-a1: #0b6abe;
|
|
129
129
|
--color-additional-a2: #1899e9;
|
|
130
130
|
--color-additional-a3: #b3f1ff;
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
--color-background-main-inverse: #f5f5f5;
|
|
31
31
|
--color-content-accent-main: #a0a0a0;
|
|
32
32
|
--color-accent-main: #181818;
|
|
33
|
-
--color-content-accent-primary: #
|
|
33
|
+
--color-content-accent-primary: #dcdcdc;
|
|
34
34
|
--color-accent-primary: #282828;
|
|
35
35
|
--color-content-accent-disabled: #606060;
|
|
36
36
|
--color-background-main-hover: #2c2c2c;
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
--color-content-primary-inverse: #fff;
|
|
30
30
|
--color-content-accent-main: #a0a0a0;
|
|
31
31
|
--color-accent-main: #181818;
|
|
32
|
-
--color-content-accent-primary: #
|
|
32
|
+
--color-content-accent-primary: #dcdcdc;
|
|
33
33
|
--color-accent-primary: #282828;
|
|
34
34
|
--color-content-accent-disabled: #606060;
|
|
35
35
|
--color-background-main: #fff;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type UseBooleanControllers = {
|
|
1
|
+
export type UseBooleanControllers = {
|
|
2
2
|
/** Установить значение в {true} */
|
|
3
3
|
on: () => void;
|
|
4
4
|
/** Установить значение в {false} */
|
|
@@ -6,8 +6,7 @@ type UseBooleanControllers = {
|
|
|
6
6
|
/** Перевести значение в противоположное состояние */
|
|
7
7
|
toggle: () => void;
|
|
8
8
|
};
|
|
9
|
-
type UseBooleanReturnValue = [boolean, UseBooleanControllers];
|
|
9
|
+
export type UseBooleanReturnValue = [boolean, UseBooleanControllers];
|
|
10
10
|
export declare function useBoolean(
|
|
11
11
|
/** Значение по умолчанию */
|
|
12
12
|
defaultValue?: boolean): UseBooleanReturnValue;
|
|
13
|
-
export {};
|
|
@@ -1,112 +1,115 @@
|
|
|
1
1
|
.Avatar {
|
|
2
2
|
--avatar-size: 100%;
|
|
3
|
+
--avatar-color: var(--color-content-action-on);
|
|
4
|
+
--avatar-bg-color: unset;
|
|
3
5
|
display: flex;
|
|
4
6
|
align-items: center;
|
|
5
7
|
justify-content: center;
|
|
6
8
|
flex-shrink: 0;
|
|
7
9
|
inline-size: var(--avatar-size);
|
|
8
10
|
block-size: var(--avatar-size);
|
|
11
|
+
color: var(--avatar-color);
|
|
12
|
+
background-color: var(--avatar-bg-color);
|
|
9
13
|
font-family: Roboto, sans-serif;
|
|
10
14
|
border-radius: 50%;
|
|
11
15
|
position: relative;
|
|
12
16
|
overflow: visible;
|
|
13
|
-
color: var(--color-content-action-on);
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
.Avatar_color_a1 {
|
|
17
|
-
|
|
20
|
+
--avatar-bg-color: var(--color-additional-a1);
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
.Avatar_color_a2 {
|
|
21
|
-
|
|
24
|
+
--avatar-bg-color: var(--color-additional-a2);
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
.Avatar_color_a3 {
|
|
25
|
-
|
|
28
|
+
--avatar-bg-color: var(--color-additional-a3);
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
.Avatar_color_b1 {
|
|
29
|
-
|
|
32
|
+
--avatar-bg-color: var(--color-additional-b1);
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
.Avatar_color_b2 {
|
|
33
|
-
|
|
36
|
+
--avatar-bg-color: var(--color-additional-b2);
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
.Avatar_color_b3 {
|
|
37
|
-
|
|
40
|
+
--avatar-bg-color: var(--color-additional-b3);
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
.Avatar_color_c1 {
|
|
41
|
-
|
|
44
|
+
--avatar-bg-color: var(--color-additional-c1);
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
.Avatar_color_c2 {
|
|
45
|
-
|
|
48
|
+
--avatar-bg-color: var(--color-additional-c2);
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
.Avatar_color_c3 {
|
|
49
|
-
|
|
52
|
+
--avatar-bg-color: var(--color-additional-c3);
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
.Avatar_color_d1 {
|
|
53
|
-
|
|
56
|
+
--avatar-bg-color: var(--color-additional-d1);
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
.Avatar_color_d2 {
|
|
57
|
-
|
|
60
|
+
--avatar-bg-color: var(--color-additional-d2);
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
.Avatar_color_d3 {
|
|
61
|
-
|
|
64
|
+
--avatar-bg-color: var(--color-additional-d3);
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
.Avatar_color_e1 {
|
|
65
|
-
|
|
68
|
+
--avatar-bg-color: var(--color-additional-e1);
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
.Avatar_color_e2 {
|
|
69
|
-
|
|
72
|
+
--avatar-bg-color: var(--color-additional-e2);
|
|
70
73
|
}
|
|
71
74
|
|
|
72
75
|
.Avatar_color_e3 {
|
|
73
|
-
|
|
76
|
+
--avatar-bg-color: var(--color-additional-e3);
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
.Avatar_color_f1 {
|
|
77
|
-
|
|
80
|
+
--avatar-bg-color: var(--color-additional-f1);
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
.Avatar_color_f2 {
|
|
81
|
-
|
|
84
|
+
--avatar-bg-color: var(--color-additional-f2);
|
|
82
85
|
}
|
|
83
86
|
|
|
84
87
|
.Avatar_color_f3 {
|
|
85
|
-
|
|
88
|
+
--avatar-bg-color: var(--color-additional-f3);
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
.Avatar_color_g1 {
|
|
89
|
-
|
|
92
|
+
--avatar-bg-color: var(--color-additional-g1);
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
.Avatar_color_g2 {
|
|
93
|
-
|
|
96
|
+
--avatar-bg-color: var(--color-additional-g2);
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
.Avatar_color_g3 {
|
|
97
|
-
|
|
100
|
+
--avatar-bg-color: var(--color-additional-g3);
|
|
98
101
|
}
|
|
99
102
|
|
|
100
103
|
.Avatar_color_h1 {
|
|
101
|
-
|
|
104
|
+
--avatar-bg-color: var(--color-additional-h1);
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
.Avatar_color_h2 {
|
|
105
|
-
|
|
108
|
+
--avatar-bg-color: var(--color-additional-h2);
|
|
106
109
|
}
|
|
107
110
|
|
|
108
111
|
.Avatar_color_h3 {
|
|
109
|
-
|
|
112
|
+
--avatar-bg-color: var(--color-additional-h3);
|
|
110
113
|
}
|
|
111
114
|
|
|
112
115
|
.Avatar-Image {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './Avatar.css';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import type { ComponentPropsWithRef, ComponentRef } from 'react';
|
|
3
|
+
import type { ComponentPropsWithRef, ComponentRef, ReactNode } from 'react';
|
|
4
4
|
import type { IndicatorProps } from '../Indicator';
|
|
5
5
|
export declare const avatarSizeVariant: readonly ["4xs", "3xs", "2xs", "xs", "s", "m", "l", "xl"];
|
|
6
6
|
export declare const avatarHueVariant: number[];
|
|
@@ -16,14 +16,14 @@ export type AvatarProps = {
|
|
|
16
16
|
/** Url изображения */
|
|
17
17
|
src?: string;
|
|
18
18
|
/** Имя пользователя */
|
|
19
|
-
name
|
|
19
|
+
name?: string;
|
|
20
20
|
/** Цветовой оттенок аватарки (при использовании без src) */
|
|
21
21
|
hue?: AvatarHueVariant;
|
|
22
22
|
/** Дополнительные СSS-классы */
|
|
23
23
|
className?: string;
|
|
24
24
|
/** Свойства компонента Indicator */
|
|
25
25
|
indicatorProps?: IndicatorProps;
|
|
26
|
-
children?:
|
|
26
|
+
children?: ReactNode;
|
|
27
27
|
} & ComponentPropsWithRef<typeof avatarEl>;
|
|
28
28
|
export declare const cnAvatar: import("@bem-react/classname").ClassNameFormatter;
|
|
29
29
|
export declare const Avatar: React.ForwardRefExoticComponent<Omit<AvatarProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -7,6 +7,7 @@ import { cn } from '../../utils/classname';
|
|
|
7
7
|
import { Indicator } from '../Indicator';
|
|
8
8
|
import { AVATAR_DEFAULT_HUE, AVATAR_DEFAULT_ONLINE, AVATAR_DEFAULT_SIZE, } from './constants';
|
|
9
9
|
import { getHashNumber } from './get-hash-number';
|
|
10
|
+
import { matchSizeIndicatorToAvatar, getInitials } from './utils';
|
|
10
11
|
export var avatarSizeVariant = [
|
|
11
12
|
'4xs',
|
|
12
13
|
'3xs',
|
|
@@ -20,38 +21,25 @@ export var avatarSizeVariant = [
|
|
|
20
21
|
export var avatarHueVariant = [1, 2, 3];
|
|
21
22
|
var avatarEl = 'div';
|
|
22
23
|
export var cnAvatar = cn('Avatar');
|
|
23
|
-
var getInitials = function (name) {
|
|
24
|
-
var _a, _b, _c;
|
|
25
|
-
var parts = name.split(' ');
|
|
26
|
-
var initials;
|
|
27
|
-
if (parts.length === 1) {
|
|
28
|
-
initials = ((_a = parts[0]) === null || _a === void 0 ? void 0 : _a.charAt(0)) || '';
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
initials = ((_b = parts.shift()) !== null && _b !== void 0 ? _b : '').charAt(0) + ((_c = parts.pop()) !== null && _c !== void 0 ? _c : '').charAt(0);
|
|
32
|
-
}
|
|
33
|
-
return initials.toUpperCase();
|
|
34
|
-
};
|
|
35
|
-
var matchSizeIndicatorToAvatar = {
|
|
36
|
-
'4xs': 'xs',
|
|
37
|
-
'3xs': 'xs',
|
|
38
|
-
'2xs': 'xs',
|
|
39
|
-
xs: 's',
|
|
40
|
-
s: 's',
|
|
41
|
-
m: 's',
|
|
42
|
-
l: 'm',
|
|
43
|
-
xl: 'm',
|
|
44
|
-
};
|
|
45
24
|
export var Avatar = forwardRef(function (inProps, ref) {
|
|
46
25
|
var props = useThemeProps({ props: inProps, name: 'Avatar' });
|
|
47
|
-
var _a = props.size, size = _a === void 0 ? AVATAR_DEFAULT_SIZE : _a, _b = props.online, online = _b === void 0 ? AVATAR_DEFAULT_ONLINE : _b, _c = props.hue, hue = _c === void 0 ? AVATAR_DEFAULT_HUE : _c, src = props.src,
|
|
26
|
+
var _a = props.size, size = _a === void 0 ? AVATAR_DEFAULT_SIZE : _a, _b = props.online, online = _b === void 0 ? AVATAR_DEFAULT_ONLINE : _b, _c = props.hue, hue = _c === void 0 ? AVATAR_DEFAULT_HUE : _c, src = props.src, nameProp = props.name, className = props.className, indicatorProps = props.indicatorProps, children = props.children, other = __rest(props, ["size", "online", "hue", "src", "name", "className", "indicatorProps", "children"]);
|
|
27
|
+
var name = nameProp || '';
|
|
48
28
|
var _d = __read(useBoolean(!!src), 2), showImage = _d[0], off = _d[1].off;
|
|
49
29
|
var indicatorSize = matchSizeIndicatorToAvatar[size];
|
|
50
30
|
var colorShades = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'];
|
|
51
31
|
var color = "".concat(colorShades[getHashNumber(name, colorShades.length)]).concat(hue);
|
|
52
|
-
var
|
|
32
|
+
var renderContent = function () {
|
|
33
|
+
if (children) {
|
|
34
|
+
return children;
|
|
35
|
+
}
|
|
36
|
+
if (src && showImage) {
|
|
37
|
+
return (React.createElement("img", { src: src, alt: name, className: cnAvatar('Image'), onError: off }));
|
|
38
|
+
}
|
|
39
|
+
return getInitials(name);
|
|
40
|
+
};
|
|
53
41
|
return (React.createElement("div", __assign({ className: cnAvatar({ size: size, color: !showImage && color }, [className]) }, other, { ref: ref }),
|
|
54
|
-
|
|
55
|
-
online && (React.createElement(Indicator, __assign({ variant: "success", size: indicatorSize, className: cnAvatar('Online'
|
|
42
|
+
renderContent(),
|
|
43
|
+
online && (React.createElement(Indicator, __assign({ variant: "success", size: indicatorSize, border: true }, indicatorProps, { className: cnAvatar('Online', indicatorProps === null || indicatorProps === void 0 ? void 0 : indicatorProps.className) })))));
|
|
56
44
|
});
|
|
57
45
|
Avatar.displayName = 'Avatar';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IndicatorSizeVariant } from '../Indicator';
|
|
2
|
+
import type { AvatarSizeVariant } from './index';
|
|
3
|
+
export declare const getInitials: (name: string) => string;
|
|
4
|
+
export declare const matchSizeIndicatorToAvatar: {
|
|
5
|
+
[key in AvatarSizeVariant]: IndicatorSizeVariant;
|
|
6
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export var getInitials = function (name) {
|
|
2
|
+
var _a, _b, _c;
|
|
3
|
+
var parts = name.split(' ');
|
|
4
|
+
var initials;
|
|
5
|
+
if (parts.length === 1) {
|
|
6
|
+
initials = ((_a = parts[0]) === null || _a === void 0 ? void 0 : _a.charAt(0)) || '';
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
initials = ((_b = parts.shift()) !== null && _b !== void 0 ? _b : '').charAt(0) + ((_c = parts.pop()) !== null && _c !== void 0 ? _c : '').charAt(0);
|
|
10
|
+
}
|
|
11
|
+
return initials.toUpperCase();
|
|
12
|
+
};
|
|
13
|
+
export var matchSizeIndicatorToAvatar = {
|
|
14
|
+
'4xs': 'xs',
|
|
15
|
+
'3xs': 'xs',
|
|
16
|
+
'2xs': 'xs',
|
|
17
|
+
xs: 's',
|
|
18
|
+
s: 's',
|
|
19
|
+
m: 's',
|
|
20
|
+
l: 'm',
|
|
21
|
+
xl: 'm',
|
|
22
|
+
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import './Button.css';
|
|
2
|
-
import React from 'react';
|
|
3
2
|
import type { ReactNode, ElementType } from 'react';
|
|
4
3
|
import type { IconProps, IconSize } from '@ozen-ui/icons';
|
|
5
4
|
import type { FormElementSizeVariant } from '../../types/FormElementSizeVariant';
|
|
6
5
|
import type { PolymorphicComponentPropsWithoutRef } from '../../utils/polymorphicComponentWithRef';
|
|
6
|
+
import type { RenderContentType } from '../../utils/renderContent';
|
|
7
7
|
import { BUTTON_DEFAULT_TAG } from './constants';
|
|
8
8
|
export declare const buttonVariant: readonly ["contained", "outlined", "ghost", "function"];
|
|
9
9
|
export declare const buttonColorVariant: readonly ["primary", "secondary", "warning", "error"];
|
|
10
10
|
export type ButtonVariant = (typeof buttonVariant)[number];
|
|
11
11
|
export type ButtonColorVariant = (typeof buttonColorVariant)[number];
|
|
12
|
-
export type
|
|
12
|
+
export type ButtonIcon = RenderContentType<IconProps & {
|
|
13
13
|
size?: IconSize;
|
|
14
|
-
}
|
|
14
|
+
}>['content'];
|
|
15
15
|
type ButtonBaseProps = {
|
|
16
16
|
/**
|
|
17
17
|
* Вариант отображения кнопки
|
|
@@ -37,9 +37,9 @@ type ButtonBaseProps = {
|
|
|
37
37
|
/** Дополнительные CSS-классы */
|
|
38
38
|
className?: string;
|
|
39
39
|
/** Иконка слева */
|
|
40
|
-
iconLeft?:
|
|
40
|
+
iconLeft?: ButtonIcon;
|
|
41
41
|
/** Иконка справа */
|
|
42
|
-
iconRight?:
|
|
42
|
+
iconRight?: ButtonIcon;
|
|
43
43
|
/** Если {true} растягивает кнопку на всю ширину родительского контейнера */
|
|
44
44
|
fullWidth?: boolean;
|
|
45
45
|
};
|
|
@@ -6,6 +6,7 @@ import { useThemeProps } from '../../hooks/useThemeProps';
|
|
|
6
6
|
import { cn } from '../../utils/classname';
|
|
7
7
|
import { getIconSizeToFormElement } from '../../utils/getIconSizeToFormElement';
|
|
8
8
|
import { polymorphicComponentWithRef } from '../../utils/polymorphicComponentWithRef';
|
|
9
|
+
import { renderContent } from '../../utils/renderContent';
|
|
9
10
|
import { Loader } from '../Loader';
|
|
10
11
|
import { BUTTON_DEFAULT_SIZE, BUTTON_DEFAULT_VARIANT, BUTTON_DEFAULT_COLOR, BUTTON_DEFAULT_TAG, } from './constants';
|
|
11
12
|
export var buttonVariant = [
|
|
@@ -28,19 +29,27 @@ export var Button = polymorphicComponentWithRef(function (inProps, ref) {
|
|
|
28
29
|
props: inProps,
|
|
29
30
|
name: 'Button',
|
|
30
31
|
});
|
|
31
|
-
var _a = props.as, Tag = _a === void 0 ? BUTTON_DEFAULT_TAG : _a, _b = props.variant, variant = _b === void 0 ? BUTTON_DEFAULT_VARIANT : _b, _c = props.color, color = _c === void 0 ? BUTTON_DEFAULT_COLOR : _c, _d = props.size, size = _d === void 0 ? BUTTON_DEFAULT_SIZE : _d,
|
|
32
|
+
var _a = props.as, Tag = _a === void 0 ? BUTTON_DEFAULT_TAG : _a, _b = props.variant, variant = _b === void 0 ? BUTTON_DEFAULT_VARIANT : _b, _c = props.color, color = _c === void 0 ? BUTTON_DEFAULT_COLOR : _c, _d = props.size, size = _d === void 0 ? BUTTON_DEFAULT_SIZE : _d, iconLeft = props.iconLeft, iconRight = props.iconRight, loading = props.loading, children = props.children, disabled = props.disabled, className = props.className, fullWidth = props.fullWidth, onClick = props.onClick, other = __rest(props, ["as", "variant", "color", "size", "iconLeft", "iconRight", "loading", "children", "disabled", "className", "fullWidth", "onClick"]);
|
|
32
33
|
var iconSize = getIconSizeToFormElement(size);
|
|
33
34
|
var handleClick = function (event) {
|
|
34
35
|
if (onClick && !disabled && !loading) {
|
|
35
36
|
onClick(event);
|
|
36
37
|
}
|
|
37
38
|
};
|
|
39
|
+
var renderIcon = function (content) {
|
|
40
|
+
return renderContent({
|
|
41
|
+
content: content,
|
|
42
|
+
props: {
|
|
43
|
+
size: getIconSizeToFormElement(size),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
};
|
|
38
47
|
var isInteractionPrevented = disabled || loading;
|
|
39
48
|
var childContent = (React.createElement(React.Fragment, null,
|
|
40
49
|
React.createElement("span", { className: cnButton('Label') },
|
|
41
|
-
|
|
50
|
+
renderIcon(iconLeft),
|
|
42
51
|
children,
|
|
43
|
-
|
|
52
|
+
renderIcon(iconRight)),
|
|
44
53
|
React.createElement(CSSTransition, { in: loading, timeout: 120, classNames: cnButton('Loader', { animation: true }), unmountOnExit: true },
|
|
45
54
|
React.createElement(Loader, { size: iconSize, color: "var(--color-content-disabled)", className: cnButton('Loader') }))));
|
|
46
55
|
return (React.createElement(Tag, __assign({ disabled: isInteractionPrevented, onClick: handleClick, type: "button", className: cnButton({
|
|
@@ -25,7 +25,7 @@ export var Card = polymorphicComponentWithRef(function (inProps, ref) {
|
|
|
25
25
|
var _a = props.size, size = _a === void 0 ? 'm' : _a, _b = props.disabled, disabled = _b === void 0 ? false : _b, _c = props.interactive, interactive = _c === void 0 ? false : _c, _d = props.borderWidth, borderWidth = _d === void 0 ? 's' : _d, _e = props.borderVariant, borderVariant = _e === void 0 ? 'solid' : _e, _f = props.borderColor, borderColor = _f === void 0 ? 'standard' : _f, _g = props.backgroundColor, backgroundColor = _g === void 0 ? 'standard' : _g, _h = props.as, Tag = _h === void 0 ? 'div' : _h, className = props.className, children = props.children, other = __rest(props, ["size", "disabled", "interactive", "borderWidth", "borderVariant", "borderColor", "backgroundColor", "as", "className", "children"]);
|
|
26
26
|
var shouldBeInteractive = !disabled && interactive;
|
|
27
27
|
var shouldShowBorder = borderWidth !== 'none';
|
|
28
|
-
return (React.createElement(Paper, __assign({ as: Tag, radius: matchBorderRadiusPaperToCard[size], background: matchBackgroundColorPaperToCard[backgroundColor] },
|
|
28
|
+
return (React.createElement(Paper, __assign({ as: Tag, radius: matchBorderRadiusPaperToCard[size], background: matchBackgroundColorPaperToCard[backgroundColor] }, (shouldBeInteractive && { tabIndex: 0 }), { "aria-disabled": disabled }, other, { ref: ref, className: cnCard(__assign({ size: size, disabled: disabled, interactive: shouldBeInteractive, backgroundColor: backgroundColor, borderWidth: borderWidth }, (shouldShowBorder && {
|
|
29
29
|
borderVariant: borderVariant,
|
|
30
30
|
borderColor: borderColor,
|
|
31
31
|
})), [className]) }), children));
|
|
@@ -158,6 +158,24 @@
|
|
|
158
158
|
.Grid_rowGap_8xl {
|
|
159
159
|
grid-row-gap: var(--space-8xl);
|
|
160
160
|
}
|
|
161
|
+
.Grid_align_start {
|
|
162
|
+
align-items: start;
|
|
163
|
+
}
|
|
164
|
+
.Grid_align_end {
|
|
165
|
+
align-items: end;
|
|
166
|
+
}
|
|
167
|
+
.Grid_align_center {
|
|
168
|
+
align-items: center;
|
|
169
|
+
}
|
|
170
|
+
.Grid_justify_start {
|
|
171
|
+
justify-items: start;
|
|
172
|
+
}
|
|
173
|
+
.Grid_justify_end {
|
|
174
|
+
justify-items: end;
|
|
175
|
+
}
|
|
176
|
+
.Grid_justify_center {
|
|
177
|
+
justify-items: center;
|
|
178
|
+
}
|
|
161
179
|
@media (min-width: 0) {
|
|
162
180
|
.Grid_gap_xs_0 {
|
|
163
181
|
grid-gap: 0;
|
|
@@ -5,6 +5,10 @@ export declare const gridColsVariant: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1
|
|
|
5
5
|
export type GridColsVariant = (typeof gridColsVariant)[number];
|
|
6
6
|
export declare const gridGapVariant: readonly ["0", "xs", "s", "m", "l", "xl", "2xl", "3xl", "4xl", "5xl", "6xl", "7xl", "8xl"];
|
|
7
7
|
export type GridGapVariant = (typeof gridGapVariant)[number];
|
|
8
|
+
export declare const gridAlignVariant: readonly ["start", "end", "center"];
|
|
9
|
+
export declare const gridJustifyVariant: readonly ["start", "end", "center"];
|
|
10
|
+
export type GridAlignVariant = (typeof gridAlignVariant)[number];
|
|
11
|
+
export type GridJustifyVariant = (typeof gridJustifyVariant)[number];
|
|
8
12
|
export declare const cnGrid: import("@bem-react/classname").ClassNameFormatter;
|
|
9
13
|
export type GridProps = {
|
|
10
14
|
/** Количество колонок в сетке */
|
|
@@ -15,6 +19,10 @@ export type GridProps = {
|
|
|
15
19
|
colGap?: ResponsiveValue<GridGapVariant>;
|
|
16
20
|
/** Отступы вокруг строки */
|
|
17
21
|
rowGap?: ResponsiveValue<GridGapVariant>;
|
|
22
|
+
/** Выравнивание */
|
|
23
|
+
align?: GridAlignVariant;
|
|
24
|
+
/** Пространство между элементами */
|
|
25
|
+
justify?: GridJustifyVariant;
|
|
18
26
|
/** Содержимое компонента */
|
|
19
27
|
children?: ReactNode;
|
|
20
28
|
/** Дополнительные СSS-классы */
|
|
@@ -23,13 +23,22 @@ export var gridGapVariant = [
|
|
|
23
23
|
'7xl',
|
|
24
24
|
'8xl',
|
|
25
25
|
];
|
|
26
|
+
export var gridAlignVariant = ['start', 'end', 'center'];
|
|
27
|
+
export var gridJustifyVariant = ['start', 'end', 'center'];
|
|
26
28
|
export var cnGrid = cn('Grid');
|
|
27
29
|
export var Grid = polymorphicComponentWithRef(function (inProps, ref) {
|
|
28
30
|
var props = useThemeProps({
|
|
29
31
|
props: inProps,
|
|
30
32
|
name: 'Grid',
|
|
31
33
|
});
|
|
32
|
-
var _a = props.cols, cols = _a === void 0 ? GRID_DEFAULT_COLS : _a, _b = props.gap, gap = _b === void 0 ? GRID_DEFAULT_GAP : _b, _c = props.as, Tag = _c === void 0 ? GRID_DEFAULT_TAG : _c, colGap = props.colGap, rowGap = props.rowGap, children = props.children, className = props.className, other = __rest(props, ["cols", "gap", "as", "colGap", "rowGap", "children", "className"]);
|
|
33
|
-
return (React.createElement(Tag, __assign({ className: classnames(cnGrid({}), useGenerateGridModsCn(cnGrid, {
|
|
34
|
+
var _a = props.cols, cols = _a === void 0 ? GRID_DEFAULT_COLS : _a, _b = props.gap, gap = _b === void 0 ? GRID_DEFAULT_GAP : _b, _c = props.as, Tag = _c === void 0 ? GRID_DEFAULT_TAG : _c, colGap = props.colGap, rowGap = props.rowGap, align = props.align, justify = props.justify, children = props.children, className = props.className, other = __rest(props, ["cols", "gap", "as", "colGap", "rowGap", "align", "justify", "children", "className"]);
|
|
35
|
+
return (React.createElement(Tag, __assign({ className: classnames(cnGrid({}), useGenerateGridModsCn(cnGrid, {
|
|
36
|
+
cols: cols,
|
|
37
|
+
gap: gap,
|
|
38
|
+
colGap: colGap,
|
|
39
|
+
rowGap: rowGap,
|
|
40
|
+
align: align,
|
|
41
|
+
justify: justify,
|
|
42
|
+
}), className) }, other, { ref: ref }), children));
|
|
34
43
|
});
|
|
35
44
|
Grid.displayName = 'Grid';
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import './IconButton.css';
|
|
2
|
-
import React from 'react';
|
|
3
2
|
import type { ElementType } from 'react';
|
|
4
3
|
import type { IconSize, IconProps } from '@ozen-ui/icons';
|
|
5
4
|
import type { FormElementSizeVariant } from '../../types/FormElementSizeVariant';
|
|
6
5
|
import type { PolymorphicComponentPropsWithoutRef } from '../../utils/polymorphicComponentWithRef';
|
|
6
|
+
import type { RenderContentType } from '../../utils/renderContent';
|
|
7
7
|
import { ICON_BUTTON_DEFAULT_TAG } from './constants';
|
|
8
8
|
export declare const iconButtonColorVariant: readonly ["primary", "secondary"];
|
|
9
9
|
export declare const iconButtonVariant: readonly ["contained", "outlined", "ghost", "function", "floating"];
|
|
10
10
|
export type IconButtonVariant = (typeof iconButtonVariant)[number];
|
|
11
11
|
export type IconButtonColorVariant = (typeof iconButtonColorVariant)[number];
|
|
12
|
-
export type
|
|
12
|
+
export type IconButtonIcon = RenderContentType<IconProps & {
|
|
13
13
|
size?: IconSize;
|
|
14
|
-
};
|
|
14
|
+
}>['content'];
|
|
15
15
|
type IconButtonBaseProps = {
|
|
16
16
|
/** Иконка */
|
|
17
|
-
icon:
|
|
17
|
+
icon: IconButtonIcon;
|
|
18
18
|
/** Вариант представления компонента */
|
|
19
19
|
variant?: IconButtonVariant;
|
|
20
20
|
/** Размер */
|
|
@@ -31,9 +31,9 @@ type IconButtonBaseProps = {
|
|
|
31
31
|
loading?: boolean;
|
|
32
32
|
/** Дополнительные CSS-классы */
|
|
33
33
|
className?: string;
|
|
34
|
-
children?: never;
|
|
35
34
|
/** Если {true} делает компонент круглым */
|
|
36
35
|
rounded?: boolean;
|
|
36
|
+
children?: never;
|
|
37
37
|
};
|
|
38
38
|
export type IconButtonProps<As extends ElementType = typeof ICON_BUTTON_DEFAULT_TAG> = PolymorphicComponentPropsWithoutRef<IconButtonBaseProps, As>;
|
|
39
39
|
export declare const cnIconButton: import("@bem-react/classname").ClassNameFormatter;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { __assign, __rest } from "tslib";
|
|
2
2
|
import './IconButton.css';
|
|
3
3
|
import React, { useMemo } from 'react';
|
|
4
|
-
import { isValidElementType } from 'react-is';
|
|
5
4
|
import { useThemeProps } from '../../hooks/useThemeProps';
|
|
6
5
|
import { cn } from '../../utils/classname';
|
|
7
6
|
import { getIconSizeToFormElement } from '../../utils/getIconSizeToFormElement';
|
|
8
7
|
import { polymorphicComponentWithRef } from '../../utils/polymorphicComponentWithRef';
|
|
8
|
+
import { renderContent } from '../../utils/renderContent';
|
|
9
9
|
import { Loader } from '../Loader';
|
|
10
10
|
import { ICON_BUTTON_DEFAULT_SIZE, ICON_BUTTON_DEFAULT_VARIANT, ICON_BUTTON_DEFAULT_COLOR, ICON_BUTTON_DEFAULT_TAG, } from './constants';
|
|
11
11
|
export var iconButtonColorVariant = ['primary', 'secondary'];
|
|
@@ -29,23 +29,31 @@ export var IconButton = polymorphicComponentWithRef(function (inProps, ref) {
|
|
|
29
29
|
props: inProps,
|
|
30
30
|
name: 'IconButton',
|
|
31
31
|
});
|
|
32
|
-
var _a = props.size, size = _a === void 0 ? ICON_BUTTON_DEFAULT_SIZE : _a, _b = props.variant, variant = _b === void 0 ? ICON_BUTTON_DEFAULT_VARIANT : _b, _c = props.color, color = _c === void 0 ? ICON_BUTTON_DEFAULT_COLOR : _c, _d = props.as, Tag = _d === void 0 ? ICON_BUTTON_DEFAULT_TAG : _d, iconColor = props.iconColor, compressed = props.compressed, loading = props.loading, disabled = props.disabled, className = props.className,
|
|
33
|
-
var iconSize = getIconSizeToFormElement(size);
|
|
32
|
+
var _a = props.size, size = _a === void 0 ? ICON_BUTTON_DEFAULT_SIZE : _a, _b = props.variant, variant = _b === void 0 ? ICON_BUTTON_DEFAULT_VARIANT : _b, _c = props.color, color = _c === void 0 ? ICON_BUTTON_DEFAULT_COLOR : _c, _d = props.as, Tag = _d === void 0 ? ICON_BUTTON_DEFAULT_TAG : _d, iconColor = props.iconColor, compressed = props.compressed, loading = props.loading, disabled = props.disabled, className = props.className, icon = props.icon, onClick = props.onClick, rounded = props.rounded, other = __rest(props, ["size", "variant", "color", "as", "iconColor", "compressed", "loading", "disabled", "className", "icon", "onClick", "rounded"]);
|
|
34
33
|
var isInteractionPrevented = disabled || loading;
|
|
35
34
|
var handleClick = function (event) {
|
|
36
35
|
if (onClick && !disabled && !loading) {
|
|
37
36
|
onClick(event);
|
|
38
37
|
}
|
|
39
38
|
};
|
|
39
|
+
var renderIcon = function (content) {
|
|
40
|
+
return renderContent({
|
|
41
|
+
content: content,
|
|
42
|
+
props: {
|
|
43
|
+
size: getIconSizeToFormElement(size),
|
|
44
|
+
color: iconColor,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
};
|
|
40
48
|
var resolvedChildren = useMemo(function () {
|
|
41
49
|
if (loading) {
|
|
42
50
|
return (React.createElement(Loader, { className: cnIconButton('Loader'), color: "var(--color-content-disabled)", size: loaderSizeMapper[size] }));
|
|
43
51
|
}
|
|
44
|
-
if (
|
|
45
|
-
return
|
|
52
|
+
if (icon) {
|
|
53
|
+
return renderIcon(icon);
|
|
46
54
|
}
|
|
47
55
|
return null;
|
|
48
|
-
}, [loading, size, iconColor,
|
|
56
|
+
}, [loading, size, iconColor, icon, renderIcon]);
|
|
49
57
|
return (React.createElement(Tag, __assign({ className: cnIconButton({
|
|
50
58
|
variant: variant,
|
|
51
59
|
size: size,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
.List {
|
|
2
|
+
--list-item-color: var(--color-content-primary);
|
|
2
3
|
--list-item-border-radius: var(--border-radius-xs);
|
|
3
|
-
--list-
|
|
4
|
+
--list-item-bg-color: transparent;
|
|
5
|
+
--list-item-bg-color-hover: var(--color-background-main-hover);
|
|
6
|
+
--list-item-bg-color-active: var(--color-background-main-pressed);
|
|
7
|
+
--list-item-bg-color-disabled: var(--color-content-tertiary);
|
|
8
|
+
--list-pipka-bg-color: var(--color-content-action);
|
|
4
9
|
--list-pipka-border-radius: 0 var(--border-radius-xs) var(--border-radius-xs)
|
|
5
10
|
0;
|
|
6
11
|
display: flex;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
min-block-size: var(--list-item-min-height);
|
|
5
5
|
padding: var(--list-item-padding);
|
|
6
6
|
border-radius: var(--list-item-border-radius);
|
|
7
|
-
color: var(--
|
|
7
|
+
color: var(--list-item-color);
|
|
8
8
|
box-sizing: border-box;
|
|
9
9
|
flex-shrink: 0;
|
|
10
10
|
margin: 0 var(--list-gutter);
|