@snack-uikit/avatar 0.6.2-preview-94780dcd.0 → 0.6.3-preview-1f246c4a.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/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 0.6.2 (2024-09-23)
7
+
8
+ ### Only dependencies have been changed
9
+ * [@snack-uikit/status@0.5.3](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/status/CHANGELOG.md)
10
+ * [@snack-uikit/utils@3.4.0](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/utils/CHANGELOG.md)
11
+
12
+
13
+
14
+
15
+
6
16
  ## 0.6.1 (2024-04-23)
7
17
 
8
18
  ### Only dependencies have been changed
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ var __rest = void 0 && (void 0).__rest || function (s, e) {
4
+ var t = {};
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
8
+ }
9
+ return t;
10
+ };
11
+ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
12
+ return mod && mod.__esModule ? mod : {
13
+ "default": mod
14
+ };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", {
17
+ value: true
18
+ });
19
+ exports.Avatar = Avatar;
20
+ const jsx_runtime_1 = require("react/jsx-runtime");
21
+ const classnames_1 = __importDefault(require("classnames"));
22
+ const react_1 = require("react");
23
+ const status_1 = require("@snack-uikit/status");
24
+ const utils_1 = require("@snack-uikit/utils");
25
+ const constants_1 = require("./constants");
26
+ const styles_module_scss_1 = __importDefault({});
27
+ const utils_2 = require("./utils");
28
+ const statusIndicatorSizeMap = {
29
+ [constants_1.SIZE.Xxs]: 'xxs',
30
+ [constants_1.SIZE.Xs]: 'xs',
31
+ [constants_1.SIZE.S]: 'xs',
32
+ [constants_1.SIZE.M]: 'm',
33
+ [constants_1.SIZE.L]: 'm',
34
+ [constants_1.SIZE.Xl]: 'l',
35
+ [constants_1.SIZE.Xxl]: 'l'
36
+ };
37
+ /**
38
+ * Компонент отображения аватара пользователя.
39
+ * @constructor
40
+ */
41
+ function Avatar(_a) {
42
+ var {
43
+ name,
44
+ appearance = constants_1.APPEARANCE.Red,
45
+ size = constants_1.SIZE.S,
46
+ shape = constants_1.SHAPE.Round,
47
+ indicator,
48
+ showTwoSymbols,
49
+ src,
50
+ className
51
+ } = _a,
52
+ rest = __rest(_a, ["name", "appearance", "size", "shape", "indicator", "showTwoSymbols", "src", "className"]);
53
+ const [imageError, setImageError] = (0, react_1.useState)(false);
54
+ const numberOfSymbols = size !== constants_1.SIZE.Xxs && showTwoSymbols ? 2 : 1;
55
+ (0, react_1.useEffect)(() => {
56
+ setImageError(false);
57
+ }, [src]);
58
+ return (0, jsx_runtime_1.jsxs)("div", Object.assign({
59
+ className: (0, classnames_1.default)(styles_module_scss_1.default.avatar, className)
60
+ }, (0, utils_1.extractSupportProps)(rest), {
61
+ "data-size": size,
62
+ "data-appearance": appearance,
63
+ "data-shape": shape,
64
+ children: [src && !imageError ? (0, jsx_runtime_1.jsx)("img", {
65
+ "data-test-id": 'image',
66
+ className: styles_module_scss_1.default.image,
67
+ src: src,
68
+ onError: () => setImageError(true),
69
+ alt: ''
70
+ }) : (0, jsx_runtime_1.jsx)("div", {
71
+ "data-test-id": 'abbreviation',
72
+ children: (0, utils_2.getAbbreviation)(name, numberOfSymbols)
73
+ }), indicator && (0, jsx_runtime_1.jsx)("div", {
74
+ className: styles_module_scss_1.default.indicatorWrapper,
75
+ children: (0, jsx_runtime_1.jsx)(status_1.StatusIndicator, {
76
+ "data-test-id": 'indicator',
77
+ appearance: indicator,
78
+ size: statusIndicatorSizeMap[size]
79
+ })
80
+ })]
81
+ }));
82
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SHAPE = exports.SIZE = exports.APPEARANCE = void 0;
7
+ exports.APPEARANCE = {
8
+ Red: 'red',
9
+ Orange: 'orange',
10
+ Yellow: 'yellow',
11
+ Green: 'green',
12
+ Blue: 'blue',
13
+ Violet: 'violet',
14
+ Pink: 'pink',
15
+ Neutral: 'neutral'
16
+ };
17
+ exports.SIZE = {
18
+ Xxs: 'xxs',
19
+ Xs: 'xs',
20
+ S: 's',
21
+ M: 'm',
22
+ L: 'l',
23
+ Xl: 'xl',
24
+ Xxl: 'xxl'
25
+ };
26
+ exports.SHAPE = {
27
+ Round: 'round',
28
+ Square: 'square'
29
+ };
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = {
8
+ enumerable: true,
9
+ get: function () {
10
+ return m[k];
11
+ }
12
+ };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ } : function (o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ });
19
+ var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", {
23
+ value: true
24
+ });
25
+ __exportStar(require("./Avatar"), exports);
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getAbbreviation = void 0;
7
+ const SPACE = ' ';
8
+ const getAbbreviation = (str, abbreviationLength) => {
9
+ var _a;
10
+ const trimStr = str.replace(/[^a-zа-яё\d\s]/gi, '').trim();
11
+ if (!trimStr || trimStr.length < abbreviationLength) {
12
+ return trimStr.toUpperCase();
13
+ }
14
+ const strParts = trimStr.split(SPACE);
15
+ let abbreviation = trimStr;
16
+ if (strParts.length > 1) {
17
+ const firstLetter = strParts[0].charAt(0);
18
+ const secondLetter = (_a = strParts[strParts.length - 1]) === null || _a === void 0 ? void 0 : _a.charAt(0);
19
+ abbreviation = `${firstLetter}${secondLetter}`.toUpperCase();
20
+ }
21
+ return abbreviation.slice(0, abbreviationLength).toUpperCase();
22
+ };
23
+ exports.getAbbreviation = getAbbreviation;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = {
8
+ enumerable: true,
9
+ get: function () {
10
+ return m[k];
11
+ }
12
+ };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ } : function (o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ });
19
+ var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", {
23
+ value: true
24
+ });
25
+ __exportStar(require("./components"), exports);
@@ -0,0 +1,26 @@
1
+ import { StatusIndicatorProps } from '@snack-uikit/status';
2
+ import { WithSupportProps } from '@snack-uikit/utils';
3
+ import { Appearance, Shape, Size } from './types';
4
+ export type AvatarProps = WithSupportProps<{
5
+ /** Имя */
6
+ name: string;
7
+ /** src аттрибут изображеня */
8
+ src?: string;
9
+ /** Внешний вид */
10
+ appearance?: Appearance;
11
+ /** Размер */
12
+ size?: Size;
13
+ /** Форма: круглая или квадратная */
14
+ shape?: Shape;
15
+ /** Индикатор */
16
+ indicator?: StatusIndicatorProps['appearance'];
17
+ /** Отображение двух заглавных символов имени */
18
+ showTwoSymbols?: boolean;
19
+ /** CSS-класс */
20
+ className?: string;
21
+ }>;
22
+ /**
23
+ * Компонент отображения аватара пользователя.
24
+ * @constructor
25
+ */
26
+ export declare function Avatar({ name, appearance, size, shape, indicator, showTwoSymbols, src, className, ...rest }: AvatarProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,23 @@
1
+ export declare const APPEARANCE: {
2
+ readonly Red: "red";
3
+ readonly Orange: "orange";
4
+ readonly Yellow: "yellow";
5
+ readonly Green: "green";
6
+ readonly Blue: "blue";
7
+ readonly Violet: "violet";
8
+ readonly Pink: "pink";
9
+ readonly Neutral: "neutral";
10
+ };
11
+ export declare const SIZE: {
12
+ readonly Xxs: "xxs";
13
+ readonly Xs: "xs";
14
+ readonly S: "s";
15
+ readonly M: "m";
16
+ readonly L: "l";
17
+ readonly Xl: "xl";
18
+ readonly Xxl: "xxl";
19
+ };
20
+ export declare const SHAPE: {
21
+ readonly Round: "round";
22
+ readonly Square: "square";
23
+ };
@@ -0,0 +1 @@
1
+ export * from './Avatar';
@@ -0,0 +1,5 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+ import { APPEARANCE, SHAPE, SIZE } from './constants';
3
+ export type Appearance = ValueOf<typeof APPEARANCE>;
4
+ export type Size = ValueOf<typeof SIZE>;
5
+ export type Shape = ValueOf<typeof SHAPE>;
@@ -0,0 +1 @@
1
+ export declare const getAbbreviation: (str: string, abbreviationLength: 1 | 2) => string;
@@ -0,0 +1 @@
1
+ export * from './components';
package/package.json CHANGED
@@ -4,15 +4,16 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Avatar",
7
- "version": "0.6.2-preview-94780dcd.0",
7
+ "version": "0.6.3-preview-1f246c4a.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
11
11
  "*.woff2"
12
12
  ],
13
13
  "description": "Пользовательский автар (с инициалами либо картинкой)",
14
- "main": "./dist/index.js",
15
- "module": "./dist/index.js",
14
+ "types": "./dist/esm/index.d.ts",
15
+ "main": "./dist/cjs/index.js",
16
+ "module": "./dist/esm/index.js",
16
17
  "homepage": "https://github.com/cloud-ru-tech/snack-uikit/tree/master/packages/avatar",
17
18
  "repository": {
18
19
  "type": "git",
@@ -24,16 +25,17 @@
24
25
  "Anna Kozlova <apkozlova@cloud.ru>"
25
26
  ],
26
27
  "files": [
27
- "dist",
28
+ "dist/cjs",
29
+ "dist/esm",
28
30
  "src",
29
31
  "./CHANGELOG.md",
30
32
  "./LICENSE"
31
33
  ],
32
34
  "license": "Apache-2.0",
33
35
  "dependencies": {
34
- "@snack-uikit/status": "0.5.3-preview-94780dcd.0",
35
- "@snack-uikit/utils": "3.3.1-preview-94780dcd.0",
36
+ "@snack-uikit/status": "0.5.4-preview-1f246c4a.0",
37
+ "@snack-uikit/utils": "3.4.1-preview-1f246c4a.0",
36
38
  "classnames": "2.3.2"
37
39
  },
38
- "gitHead": "0b67805c876ec8ccc1567d110a3b37b04d2f0fb6"
40
+ "gitHead": "a185a55c0722b19f70dd168cf299e6f53a0fd93f"
39
41
  }
@@ -1,182 +0,0 @@
1
- .avatar{
2
- position:relative;
3
- display:inline-flex;
4
- flex-shrink:0;
5
- align-items:center;
6
- justify-content:center;
7
- }
8
- .avatar[data-appearance=red]{
9
- color:var(--sys-red-text-main, #7a2d2d);
10
- background-color:var(--sys-red-decor-default, #fdd6cd);
11
- }
12
- .avatar[data-appearance=orange]{
13
- color:var(--sys-orange-text-main, #884c23);
14
- background-color:var(--sys-orange-decor-default, #fed8b8);
15
- }
16
- .avatar[data-appearance=yellow]{
17
- color:var(--sys-yellow-text-main, #815f19);
18
- background-color:var(--sys-yellow-decor-default, #f0dfb1);
19
- }
20
- .avatar[data-appearance=green]{
21
- color:var(--sys-green-text-main, #3d6035);
22
- background-color:var(--sys-green-decor-default, #d2ead0);
23
- }
24
- .avatar[data-appearance=blue]{
25
- color:var(--sys-blue-text-main, #2b537e);
26
- background-color:var(--sys-blue-decor-default, #d6e2f4);
27
- }
28
- .avatar[data-appearance=violet]{
29
- color:var(--sys-violet-text-main, #59446a);
30
- background-color:var(--sys-violet-decor-default, #e6dcf3);
31
- }
32
- .avatar[data-appearance=pink]{
33
- color:var(--sys-pink-text-main, #754158);
34
- background-color:var(--sys-pink-decor-default, #f5d9e1);
35
- }
36
- .avatar[data-appearance=neutral]{
37
- color:var(--sys-neutral-text-main, #41424e);
38
- background-color:var(--sys-neutral-decor-default, #dde0ea);
39
- }
40
- .avatar[data-size=xxs]{
41
- font-family:var(--sans-label-s-font-family, SB Sans Interface);
42
- font-weight:var(--sans-label-s-font-weight, Semibold);
43
- line-height:var(--sans-label-s-line-height, 14px);
44
- font-size:var(--sans-label-s-font-size, 11px);
45
- letter-spacing:var(--sans-label-s-letter-spacing, 0px);
46
- paragraph-spacing:var(--sans-label-s-paragraph-spacing, 6.05px);
47
- }
48
- .avatar[data-size=xxs][data-shape=round]{
49
- border-radius:var(--radius-avatar-round-xxs, 8px);
50
- width:var(--size-avatar-xxs, 16px);
51
- height:var(--size-avatar-xxs, 16px);
52
- }
53
- .avatar[data-size=xxs][data-shape=square]{
54
- border-radius:var(--radius-avatar-square-xxs, 4px);
55
- width:var(--size-avatar-xxs, 16px);
56
- height:var(--size-avatar-xxs, 16px);
57
- }
58
- .avatar[data-size=xs]{
59
- font-family:var(--sans-label-s-font-family, SB Sans Interface);
60
- font-weight:var(--sans-label-s-font-weight, Semibold);
61
- line-height:var(--sans-label-s-line-height, 14px);
62
- font-size:var(--sans-label-s-font-size, 11px);
63
- letter-spacing:var(--sans-label-s-letter-spacing, 0px);
64
- paragraph-spacing:var(--sans-label-s-paragraph-spacing, 6.05px);
65
- }
66
- .avatar[data-size=xs][data-shape=round]{
67
- border-radius:var(--radius-avatar-round-xs, 16px);
68
- width:var(--size-avatar-xs, 24px);
69
- height:var(--size-avatar-xs, 24px);
70
- }
71
- .avatar[data-size=xs][data-shape=square]{
72
- border-radius:var(--radius-avatar-square-xs, 4px);
73
- width:var(--size-avatar-xs, 24px);
74
- height:var(--size-avatar-xs, 24px);
75
- }
76
- .avatar[data-size=s]{
77
- font-family:var(--sans-label-l-font-family, SB Sans Interface);
78
- font-weight:var(--sans-label-l-font-weight, Semibold);
79
- line-height:var(--sans-label-l-line-height, 20px);
80
- font-size:var(--sans-label-l-font-size, 14px);
81
- letter-spacing:var(--sans-label-l-letter-spacing, 0px);
82
- paragraph-spacing:var(--sans-label-l-paragraph-spacing, 7.7px);
83
- }
84
- .avatar[data-size=s][data-shape=round]{
85
- border-radius:var(--radius-avatar-round-s, 24px);
86
- width:var(--size-avatar-s, 32px);
87
- height:var(--size-avatar-s, 32px);
88
- }
89
- .avatar[data-size=s][data-shape=square]{
90
- border-radius:var(--radius-avatar-square-s, 4px);
91
- width:var(--size-avatar-s, 32px);
92
- height:var(--size-avatar-s, 32px);
93
- }
94
- .avatar[data-size=m]{
95
- font-family:var(--sans-title-l-font-family, SB Sans Interface);
96
- font-weight:var(--sans-title-l-font-weight, Semibold);
97
- line-height:var(--sans-title-l-line-height, 28px);
98
- font-size:var(--sans-title-l-font-size, 20px);
99
- letter-spacing:var(--sans-title-l-letter-spacing, 0.15px);
100
- paragraph-spacing:var(--sans-title-l-paragraph-spacing, 11px);
101
- }
102
- .avatar[data-size=m][data-shape=round]{
103
- border-radius:var(--radius-avatar-round-m, 24px);
104
- width:var(--size-avatar-m, 48px);
105
- height:var(--size-avatar-m, 48px);
106
- }
107
- .avatar[data-size=m][data-shape=square]{
108
- border-radius:var(--radius-avatar-square-m, 8px);
109
- width:var(--size-avatar-m, 48px);
110
- height:var(--size-avatar-m, 48px);
111
- }
112
- .avatar[data-size=l]{
113
- font-family:var(--sans-headline-m-font-family, SB Sans Interface);
114
- font-weight:var(--sans-headline-m-font-weight, Semibold);
115
- line-height:var(--sans-headline-m-line-height, 36px);
116
- font-size:var(--sans-headline-m-font-size, 28px);
117
- letter-spacing:var(--sans-headline-m-letter-spacing, -0.5px);
118
- paragraph-spacing:var(--sans-headline-m-paragraph-spacing, 15.4px);
119
- }
120
- .avatar[data-size=l][data-shape=round]{
121
- border-radius:var(--radius-avatar-round-l, 32px);
122
- width:var(--size-avatar-l, 64px);
123
- height:var(--size-avatar-l, 64px);
124
- }
125
- .avatar[data-size=l][data-shape=square]{
126
- border-radius:var(--radius-avatar-square-l, 16px);
127
- width:var(--size-avatar-l, 64px);
128
- height:var(--size-avatar-l, 64px);
129
- }
130
- .avatar[data-size=xl]{
131
- font-family:var(--sans-display-s-font-family, SB Sans Interface);
132
- font-weight:var(--sans-display-s-font-weight, Semibold);
133
- line-height:var(--sans-display-s-line-height, 48px);
134
- font-size:var(--sans-display-s-font-size, 40px);
135
- letter-spacing:var(--sans-display-s-letter-spacing, -0.5px);
136
- paragraph-spacing:var(--sans-display-s-paragraph-spacing, 22px);
137
- }
138
- .avatar[data-size=xl][data-shape=round]{
139
- border-radius:var(--radius-avatar-round-xl, 48px);
140
- width:var(--size-avatar-xl, 88px);
141
- height:var(--size-avatar-xl, 88px);
142
- }
143
- .avatar[data-size=xl][data-shape=square]{
144
- border-radius:var(--radius-avatar-square-xl, 24px);
145
- width:var(--size-avatar-xl, 88px);
146
- height:var(--size-avatar-xl, 88px);
147
- }
148
- .avatar[data-size=xxl]{
149
- font-family:var(--sans-display-m-font-family, SB Sans Interface);
150
- font-weight:var(--sans-display-m-font-weight, Semibold);
151
- line-height:var(--sans-display-m-line-height, 60px);
152
- font-size:var(--sans-display-m-font-size, 48px);
153
- letter-spacing:var(--sans-display-m-letter-spacing, -0.5px);
154
- paragraph-spacing:var(--sans-display-m-paragraph-spacing, 26.4px);
155
- }
156
- .avatar[data-size=xxl][data-shape=round]{
157
- border-radius:var(--radius-avatar-round-xxl, 64px);
158
- width:var(--size-avatar-xxl, 112px);
159
- height:var(--size-avatar-xxl, 112px);
160
- }
161
- .avatar[data-size=xxl][data-shape=square]{
162
- border-radius:var(--radius-avatar-square-xxl, 24px);
163
- width:var(--size-avatar-xxl, 112px);
164
- height:var(--size-avatar-xxl, 112px);
165
- }
166
-
167
- .image{
168
- width:100%;
169
- height:100%;
170
- -o-object-fit:cover;
171
- object-fit:cover;
172
- -o-object-position:center;
173
- object-position:center;
174
- border-radius:inherit;
175
- }
176
-
177
- .indicatorWrapper{
178
- position:absolute;
179
- right:0;
180
- bottom:0;
181
- display:inline-flex;
182
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes