@synerise/ds-avatar 1.0.12 → 1.0.13
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 +507 -1780
- package/README.md +4 -5
- package/dist/Avatar.d.ts +1 -1
- package/dist/Avatar.js +2 -2
- package/dist/Avatar.styles.js +8 -10
- package/dist/Avatar.types.d.ts +3 -3
- package/dist/ObjectAvatar/ObjectAvatar.d.ts +1 -1
- package/dist/ObjectAvatar/ObjectAvatar.js +3 -3
- package/dist/UserAvatar/UserAvatar.d.ts +1 -1
- package/dist/UserAvatar/UserAvatar.js +3 -3
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +24 -9
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
## General guidelines
|
|
3
2
|
|
|
4
3
|
An avatar is an object used to represent a particular person in the application. The avatar is usually accompanied by the status (for example, **Active**, **Inactive**, **Blocked**) identifying the availability of any person in the application.
|
|
@@ -129,7 +128,7 @@ import Avatar from '@synerise/ds-avatar';
|
|
|
129
128
|
## API
|
|
130
129
|
|
|
131
130
|
| Property | Description | Type | Default |
|
|
132
|
-
|
|
131
|
+
| ------------------ | -------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | -------- |
|
|
133
132
|
| backgroundColor | Background color of the avatar | `green` / `grey` / `yellow` / `blue` / `pink`/ `mars`/ `orange`/ `fern`/ `cyan`/ `purple` / `violet` | `orange` |
|
|
134
133
|
| backgroundColorHue | Background color hue of the avatar | `900` / `800` / `700` / `600` / `500` / `400` / `300` / `200` / `100` / `050` | `400` |
|
|
135
134
|
| disabled | Determines if avatar is disabled | boolean | `false` |
|
|
@@ -159,7 +158,7 @@ import { UserAvatar } from '@synerise/ds-avatar';
|
|
|
159
158
|
```
|
|
160
159
|
|
|
161
160
|
| Property | Description | Type | Default |
|
|
162
|
-
|
|
161
|
+
| --------------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | -------- |
|
|
163
162
|
| user | User information | { firstName: string, lastName: string, email: string, avatar: string } | - |
|
|
164
163
|
| backgroundColor | Background color of the avatar | `auto` / `green` / `grey` / `yellow` / `blue` / `pink`/ `mars`/ `orange`/ `fern`/ `cyan`/ `purple` / `violet` | `auto` |
|
|
165
164
|
| badgeStatus | Badge status | `active` / `error` / `warning` | - |
|
|
@@ -170,7 +169,7 @@ import { UserAvatar } from '@synerise/ds-avatar';
|
|
|
170
169
|
|
|
171
170
|
## ObjectAvatar
|
|
172
171
|
|
|
173
|
-
A variant that renders full standard object avatar.
|
|
172
|
+
A variant that renders full standard object avatar.
|
|
174
173
|
|
|
175
174
|
This component should be used for ex. in products, services, etc.
|
|
176
175
|
|
|
@@ -185,7 +184,7 @@ import { ObjectAvatar } from '@synerise/ds-avatar';
|
|
|
185
184
|
```
|
|
186
185
|
|
|
187
186
|
| | Property | Description | Type | Default |
|
|
188
|
-
|
|
187
|
+
| --------------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | -------- | ------- |
|
|
189
188
|
| object | Object information | { name: string, description: string, status: string, avatar: string } | - | |
|
|
190
189
|
| color | Background color of the avatar | `green` / `grey` / `yellow` / `blue` / `pink`/ `mars`/ `orange`/ `fern`/ `cyan`/ `purple` / `violet` | `grey` | |
|
|
191
190
|
| backgroundColor | Background color of the avatar | `auto` / `green` / `grey` / `yellow` / `blue` / `pink`/ `mars`/ `orange`/ `fern`/ `cyan`/ `purple` / `violet` | `auto` | |
|
package/dist/Avatar.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import '@synerise/ds-core/dist/js/style';
|
|
3
|
-
import { AvatarProps } from './Avatar.types';
|
|
3
|
+
import { type AvatarProps } from './Avatar.types';
|
|
4
4
|
import './style/index.less';
|
|
5
5
|
export declare const DEFAULT_SIZE = "medium";
|
|
6
6
|
export declare const ICON_SIZES: {
|
package/dist/Avatar.js
CHANGED
|
@@ -3,11 +3,11 @@ var _excluded = ["backgroundColor", "backgroundColorHue", "children", "disabled"
|
|
|
3
3
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
4
4
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
5
5
|
import React, { cloneElement } from 'react';
|
|
6
|
-
import Tooltip from '@synerise/ds-tooltip';
|
|
7
6
|
import '@synerise/ds-core/dist/js/style';
|
|
8
|
-
import
|
|
7
|
+
import Tooltip from '@synerise/ds-tooltip';
|
|
9
8
|
import AntdAvatar from './Avatar.styles';
|
|
10
9
|
import "./style/index.css";
|
|
10
|
+
import { getTooltipProps, isIconComponent } from './utils';
|
|
11
11
|
export var DEFAULT_SIZE = 'medium';
|
|
12
12
|
export var ICON_SIZES = {
|
|
13
13
|
small: 16,
|
package/dist/Avatar.styles.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var _excluded = ["backgroundColorHue", "backgroundColor", "onClick", "hasStatus", "hasTooltip"];
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
3
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
|
+
import Avatar from 'antd/lib/avatar';
|
|
4
5
|
import React from 'react';
|
|
5
6
|
import styled, { css } from 'styled-components';
|
|
6
|
-
import Avatar from 'antd/lib/avatar';
|
|
7
|
-
import { macro } from '@synerise/ds-typography';
|
|
8
7
|
import { IconBadgeIcon } from '@synerise/ds-badge/dist/IconBadge/IconBadge.styles';
|
|
8
|
+
import { macro } from '@synerise/ds-typography';
|
|
9
9
|
export var TooltipGroup = styled.div.withConfig({
|
|
10
10
|
displayName: "Avatarstyles__TooltipGroup",
|
|
11
11
|
componentId: "sc-xcn5o4-0"
|
|
@@ -36,11 +36,11 @@ var ICON_BADGE_POSITION = {
|
|
|
36
36
|
squarelarge: '-11px',
|
|
37
37
|
squareextraLarge: '-11px'
|
|
38
38
|
};
|
|
39
|
-
var
|
|
40
|
-
small:
|
|
41
|
-
medium:
|
|
42
|
-
large:
|
|
43
|
-
extraLarge:
|
|
39
|
+
var MACRO_MAPPING = {
|
|
40
|
+
small: macro.xsAvatar,
|
|
41
|
+
medium: macro.small,
|
|
42
|
+
large: macro.small,
|
|
43
|
+
extraLarge: macro.xlAvatar
|
|
44
44
|
};
|
|
45
45
|
var applyIconBadgePosition = function applyIconBadgePosition(props) {
|
|
46
46
|
var _props$shape = props.shape,
|
|
@@ -57,10 +57,8 @@ var applyBadgePosition = function applyBadgePosition(props) {
|
|
|
57
57
|
return css(["top:", ";right:", ";"], BADGE_POSITION["" + shape + size] || '0', BADGE_POSITION["" + shape + size] || '0');
|
|
58
58
|
};
|
|
59
59
|
var applyFontSize = function applyFontSize(props) {
|
|
60
|
-
return css(["", ";"],
|
|
60
|
+
return css(["", ";"], MACRO_MAPPING["" + props.size]);
|
|
61
61
|
};
|
|
62
|
-
|
|
63
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
64
62
|
export default styled(function (_ref) {
|
|
65
63
|
var backgroundColorHue = _ref.backgroundColorHue,
|
|
66
64
|
backgroundColor = _ref.backgroundColor,
|
package/dist/Avatar.types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type AvatarProps as AntAvatarProps } from 'antd/lib/avatar';
|
|
2
|
+
import type { MouseEvent as ReactMouseEvent, ReactNode } from 'react';
|
|
2
3
|
import type { BadgeStatus } from '@synerise/ds-badge';
|
|
3
|
-
import {
|
|
4
|
-
import { TooltipProps } from '@synerise/ds-tooltip/dist/Tooltip.types';
|
|
4
|
+
import { type TooltipProps } from '@synerise/ds-tooltip';
|
|
5
5
|
export type Color = 'red' | 'green' | 'grey' | 'yellow' | 'blue' | 'pink' | 'mars' | 'orange' | 'fern' | 'cyan' | 'purple' | 'violet';
|
|
6
6
|
export type ColorHue = '900' | '800' | '700' | '600' | '500' | '400' | '300' | '200' | '100' | '050';
|
|
7
7
|
export type Size = 'small' | 'medium' | 'large' | 'extraLarge' | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ObjectAvatarProps } from '../Avatar.types';
|
|
2
|
+
import { type ObjectAvatarProps } from '../Avatar.types';
|
|
3
3
|
export declare const DEFAULT_COLOR_HUE = "600";
|
|
4
4
|
export declare const DEFAULT_COLOR = "grey";
|
|
5
5
|
declare const ObjectAvatar: ({ backgroundColor, badgeStatus, iconComponent, color, object, size, src, tooltip, text, children, disabled, style, ...restProps }: ObjectAvatarProps) => React.JSX.Element;
|
|
@@ -2,12 +2,12 @@ var _excluded = ["backgroundColor", "badgeStatus", "iconComponent", "color", "ob
|
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
3
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import Icon, { MailM } from '@synerise/ds-icon';
|
|
6
|
-
import { theme } from '@synerise/ds-core';
|
|
7
5
|
import Badge from '@synerise/ds-badge';
|
|
6
|
+
import { theme } from '@synerise/ds-core';
|
|
7
|
+
import Icon, { MailM } from '@synerise/ds-icon';
|
|
8
8
|
import Status from '@synerise/ds-status';
|
|
9
9
|
import Avatar from '../Avatar';
|
|
10
|
-
import {
|
|
10
|
+
import { addIconColor, getColorByText, getObjectName } from '../utils';
|
|
11
11
|
export var DEFAULT_COLOR_HUE = '600';
|
|
12
12
|
export var DEFAULT_COLOR = 'grey';
|
|
13
13
|
var ObjectAvatar = function ObjectAvatar(_ref) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { UserAvatarProps } from '../Avatar.types';
|
|
2
|
+
import { type UserAvatarProps } from '../Avatar.types';
|
|
3
3
|
export declare const DEFAULT_COLOR = "grey";
|
|
4
4
|
export declare const DEFAULT_COLOR_HUE = "500";
|
|
5
5
|
declare const UserAvatar: React.FC<UserAvatarProps>;
|
|
@@ -2,11 +2,11 @@ var _excluded = ["backgroundColor", "size", "text", "tooltip", "badgeStatus", "u
|
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
3
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import Icon, { UserM, UserS } from '@synerise/ds-icon';
|
|
6
|
-
import { theme } from '@synerise/ds-core';
|
|
7
5
|
import Badge from '@synerise/ds-badge';
|
|
6
|
+
import { theme } from '@synerise/ds-core';
|
|
7
|
+
import Icon, { UserM, UserS } from '@synerise/ds-icon';
|
|
8
8
|
import Avatar from '../Avatar';
|
|
9
|
-
import {
|
|
9
|
+
import { addIconColor, getColorByText, getUserText } from '../utils';
|
|
10
10
|
export var DEFAULT_COLOR = 'grey';
|
|
11
11
|
export var DEFAULT_COLOR_HUE = '500';
|
|
12
12
|
var UserAvatar = function UserAvatar(_ref) {
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactElement, ReactNode } from 'react';
|
|
2
|
-
import { Color, ColorHue,
|
|
1
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
import { type AvatarProps, type Color, type ColorHue, type TooltipObject, type UserAvatar } from './Avatar.types';
|
|
3
3
|
export declare function getUserText(user: UserAvatar, src?: string | null, text?: string | null): string | null;
|
|
4
4
|
export declare function isIconComponent(component: ReactNode | undefined): boolean;
|
|
5
5
|
export declare function getObjectName(name?: string | null, text?: string): string | null;
|
package/dist/utils.js
CHANGED
|
@@ -20,10 +20,18 @@ export function getUserText(user, src, text) {
|
|
|
20
20
|
email = _user$email === void 0 ? '' : _user$email,
|
|
21
21
|
_user$avatar = user.avatar,
|
|
22
22
|
avatar = _user$avatar === void 0 ? '' : _user$avatar;
|
|
23
|
-
if (src || avatar)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (
|
|
23
|
+
if (src || avatar) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
if (text) {
|
|
27
|
+
return text;
|
|
28
|
+
}
|
|
29
|
+
if (firstName || lastName) {
|
|
30
|
+
return "" + getFirstLetter(firstName) + getFirstLetter(lastName);
|
|
31
|
+
}
|
|
32
|
+
if (email) {
|
|
33
|
+
return getFirstLetter(email);
|
|
34
|
+
}
|
|
27
35
|
return null;
|
|
28
36
|
}
|
|
29
37
|
export function isIconComponent(component) {
|
|
@@ -36,8 +44,12 @@ export function getObjectName(name, text) {
|
|
|
36
44
|
if (text === void 0) {
|
|
37
45
|
text = '';
|
|
38
46
|
}
|
|
39
|
-
if (text)
|
|
40
|
-
|
|
47
|
+
if (text) {
|
|
48
|
+
return text.toUpperCase();
|
|
49
|
+
}
|
|
50
|
+
if (name) {
|
|
51
|
+
return name.substr(0, 1).toUpperCase();
|
|
52
|
+
}
|
|
41
53
|
return null;
|
|
42
54
|
}
|
|
43
55
|
export function addIconColor(iconComponent, color) {
|
|
@@ -52,7 +64,9 @@ export function addIconColor(iconComponent, color) {
|
|
|
52
64
|
}
|
|
53
65
|
export function getColorByText(text, backgroundColor) {
|
|
54
66
|
var _ref;
|
|
55
|
-
if (backgroundColor && backgroundColor.indexOf('-') !== -1)
|
|
67
|
+
if (backgroundColor && backgroundColor.indexOf('-') !== -1) {
|
|
68
|
+
return backgroundColor.split('-');
|
|
69
|
+
}
|
|
56
70
|
var autoColor = ((_ref = typeof text === 'string' ? selectColorByLetter(text.slice(0, 1), true) : {}) == null ? void 0 : _ref.color) || 'grey';
|
|
57
71
|
var color = text && backgroundColor && backgroundColor !== 'auto' ? backgroundColor : autoColor;
|
|
58
72
|
var hue = text ? '500' : '100';
|
|
@@ -65,12 +79,13 @@ export function getTooltipProps(tooltip) {
|
|
|
65
79
|
}) : {};
|
|
66
80
|
var tooltipType = ['title', 'description', 'status'].reduce(function (prev, next) {
|
|
67
81
|
return tooltipProps[next] ? prev + 1 : prev;
|
|
68
|
-
}, 0) === 1 ? 'default' : '
|
|
82
|
+
}, 0) === 1 ? 'default' : 'largeSimple';
|
|
69
83
|
var finalTooltipProps = tooltipType === 'default' ? _extends({}, tooltipProps, {
|
|
70
84
|
title: tooltipProps.title || tooltipProps.description || tooltipProps.status,
|
|
71
85
|
type: 'default'
|
|
72
86
|
}) : _extends({}, tooltipProps, {
|
|
73
|
-
type: '
|
|
87
|
+
type: 'largeSimple'
|
|
74
88
|
});
|
|
75
89
|
return finalTooltipProps;
|
|
90
|
+
return tooltipProps;
|
|
76
91
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-avatar",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "Avatar UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "synerise/synerise-design",
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
],
|
|
35
35
|
"types": "dist/index.d.ts",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@synerise/ds-badge": "^1.0.
|
|
38
|
-
"@synerise/ds-icon": "^1.5.
|
|
39
|
-
"@synerise/ds-status": "^1.2.
|
|
40
|
-
"@synerise/ds-tooltip": "^1.1.
|
|
41
|
-
"@synerise/ds-typography": "^1.0.
|
|
42
|
-
"@synerise/ds-utils": "^1.3.
|
|
37
|
+
"@synerise/ds-badge": "^1.0.13",
|
|
38
|
+
"@synerise/ds-icon": "^1.5.4",
|
|
39
|
+
"@synerise/ds-status": "^1.2.8",
|
|
40
|
+
"@synerise/ds-tooltip": "^1.1.12",
|
|
41
|
+
"@synerise/ds-typography": "^1.0.13",
|
|
42
|
+
"@synerise/ds-utils": "^1.3.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@synerise/ds-core": "*",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"react": ">=16.9.0 <= 18.3.1",
|
|
48
48
|
"styled-components": "^5.3.3"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "4512641033ba3581a3df208143c547fcfed45895"
|
|
51
51
|
}
|