@doist/reactist 31.2.0 → 32.0.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 +16 -0
- package/dist/reactist.cjs.development.js +276 -112
- package/dist/reactist.cjs.development.js.map +1 -1
- package/dist/reactist.cjs.production.min.js +1 -1
- package/dist/reactist.cjs.production.min.js.map +1 -1
- package/es/avatar/avatar.js +164 -95
- package/es/avatar/avatar.js.map +1 -1
- package/es/avatar/avatar.module.css.js +1 -1
- package/es/avatar/utils.js +112 -16
- package/es/avatar/utils.js.map +1 -1
- package/es/tooltip/tooltip.module.css.js +1 -1
- package/es/utils/polymorphism.js.map +1 -1
- package/lib/avatar/avatar.d.ts +55 -17
- package/lib/avatar/avatar.js +164 -94
- package/lib/avatar/avatar.js.map +1 -1
- package/lib/avatar/avatar.module.css.js +1 -1
- package/lib/avatar/utils.d.ts +35 -3
- package/lib/avatar/utils.js +117 -16
- package/lib/avatar/utils.js.map +1 -1
- package/lib/modal/modal-stories-components.d.ts +0 -10
- package/lib/tooltip/tooltip.module.css.js +1 -1
- package/lib/utils/polymorphism.d.ts +1 -1
- package/lib/utils/polymorphism.js.map +1 -1
- package/package.json +4 -6
- package/styles/avatar.css +1 -1
- package/styles/avatar.module.css.css +1 -1
- package/styles/banner.css +1 -1
- package/styles/button.css +1 -1
- package/styles/index.css +2 -4
- package/styles/modal.css +1 -1
- package/styles/password-field.css +1 -1
- package/styles/reactist.css +2 -2
- package/styles/static-toast.css +1 -1
- package/styles/tooltip.css +1 -1
- package/styles/tooltip.module.css.css +1 -1
- package/styles/use-toasts.css +1 -1
package/lib/avatar/avatar.d.ts
CHANGED
|
@@ -1,21 +1,59 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { ObfuscatedClassName } from '../utils/common-types';
|
|
3
|
-
import type {
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
import type { PolymorphicComponentProps } from '../utils/polymorphism';
|
|
4
|
+
import type { AvatarImage as AvatarImageProp, AvatarShape, AvatarSize } from './utils';
|
|
5
|
+
/**
|
|
6
|
+
* Props for the `Avatar` component.
|
|
7
|
+
*/
|
|
8
|
+
type AvatarOwnProps = ObfuscatedClassName & {
|
|
9
|
+
/**
|
|
10
|
+
* The rendered avatar size, in CSS pixels.
|
|
11
|
+
*/
|
|
12
|
+
size: AvatarSize;
|
|
13
|
+
/**
|
|
14
|
+
* The avatar shape.
|
|
15
|
+
*
|
|
16
|
+
* @default 'circle'
|
|
17
|
+
*/
|
|
18
|
+
shape?: AvatarShape;
|
|
19
|
+
/**
|
|
20
|
+
* The display name represented by the avatar.
|
|
21
|
+
*
|
|
22
|
+
* Used as the default accessible label, to generate fallback initials, and
|
|
23
|
+
* to assign the deterministic background color when rendering initials.
|
|
24
|
+
*/
|
|
25
|
+
name?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The avatar image.
|
|
28
|
+
*
|
|
29
|
+
* Pass a string for a single image URL, or a source map keyed by intrinsic
|
|
30
|
+
* image width. Source maps render as native `srcSet`/`sizes` hints, with
|
|
31
|
+
* the largest valid source used as the fallback `src`.
|
|
32
|
+
*/
|
|
33
|
+
image?: AvatarImageProp;
|
|
34
|
+
/**
|
|
35
|
+
* Accessible text for the avatar image.
|
|
36
|
+
*
|
|
37
|
+
* Defaults to `name`. Pass an empty string when the avatar is decorative.
|
|
38
|
+
*/
|
|
39
|
+
alt?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Test identifier applied to the avatar root element.
|
|
42
|
+
*/
|
|
43
|
+
'data-testid'?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Avatar owns its root sizing styles. Use `exceptionallySetClassName` for the styling escape
|
|
46
|
+
* hatch.
|
|
47
|
+
*/
|
|
48
|
+
style?: never;
|
|
16
49
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
50
|
+
type AvatarProps<ComponentType extends React.ElementType = 'div'> = PolymorphicComponentProps<ComponentType, AvatarOwnProps, 'omitClassName'>;
|
|
51
|
+
/**
|
|
52
|
+
* Displays an avatar from an image URL, a source map keyed by intrinsic
|
|
53
|
+
* image width, or initials derived from the provided name (with a background
|
|
54
|
+
* color).
|
|
55
|
+
*/
|
|
56
|
+
declare const Avatar: import("../utils/polymorphism").PolymorphicComponent<"div", AvatarOwnProps, "omitClassName">;
|
|
21
57
|
export { Avatar };
|
|
58
|
+
export type { AvatarProps };
|
|
59
|
+
export type { AvatarImage, AvatarShape, AvatarSize } from './utils';
|
package/lib/avatar/avatar.js
CHANGED
|
@@ -5,8 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
6
6
|
var reactCompilerRuntime = require('react-compiler-runtime');
|
|
7
7
|
var React = require('react');
|
|
8
|
+
var classNames = require('classnames');
|
|
8
9
|
var box = require('../box/box.js');
|
|
9
|
-
var
|
|
10
|
+
var polymorphism = require('../utils/polymorphism.js');
|
|
10
11
|
var utils = require('./utils.js');
|
|
11
12
|
var avatar_module = require('./avatar.module.css.js');
|
|
12
13
|
|
|
@@ -32,109 +33,178 @@ function _interopNamespace(e) {
|
|
|
32
33
|
|
|
33
34
|
var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
|
|
34
35
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
36
|
+
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Props for the `Avatar` component.
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Displays an avatar from an image URL, a source map keyed by intrinsic
|
|
44
|
+
* image width, or initials derived from the provided name (with a background
|
|
45
|
+
* color).
|
|
46
|
+
*/
|
|
47
|
+
const Avatar = polymorphism.polymorphicComponent(function Avatar({
|
|
48
|
+
as,
|
|
49
|
+
size,
|
|
50
|
+
shape = 'circle',
|
|
51
|
+
name,
|
|
52
|
+
image,
|
|
53
|
+
alt,
|
|
54
|
+
exceptionallySetClassName,
|
|
55
|
+
'data-testid': testId,
|
|
56
|
+
'aria-hidden': ariaHidden,
|
|
57
|
+
'aria-label': ariaLabel,
|
|
58
|
+
...restProps
|
|
59
|
+
}, ref) {
|
|
60
|
+
const label = getAvatarLabel({
|
|
61
|
+
alt,
|
|
62
|
+
name,
|
|
63
|
+
'aria-label': ariaLabel
|
|
64
|
+
});
|
|
65
|
+
const isDecorative = Boolean(ariaHidden ?? label === '');
|
|
66
|
+
return /*#__PURE__*/React__namespace.createElement(box.Box, _extends__default["default"]({
|
|
67
|
+
as: as,
|
|
68
|
+
ref: ref,
|
|
69
|
+
className: classNames__default["default"](avatar_module["default"].avatar, avatar_module["default"][`size-${size}`], avatar_module["default"][`shape-${shape}`], exceptionallySetClassName),
|
|
70
|
+
"data-testid": testId,
|
|
71
|
+
display: "inlineFlex",
|
|
72
|
+
alignItems: "center",
|
|
73
|
+
justifyContent: "center",
|
|
74
|
+
flexShrink: 0,
|
|
75
|
+
overflow: "hidden",
|
|
76
|
+
textAlign: "center"
|
|
77
|
+
}, restProps), /*#__PURE__*/React__namespace.createElement(AvatarImage
|
|
78
|
+
// Allows `AvatarImage` to remount when the image map changes,
|
|
79
|
+
// which resets error states without replacing the avatar root.
|
|
80
|
+
, {
|
|
81
|
+
key: utils.getAvatarImageIdentityKey(image),
|
|
82
|
+
size: size,
|
|
83
|
+
name: name,
|
|
84
|
+
image: image,
|
|
85
|
+
label: label,
|
|
86
|
+
"aria-hidden": isDecorative
|
|
87
|
+
}));
|
|
88
|
+
});
|
|
89
|
+
function getAvatarLabel({
|
|
90
|
+
alt,
|
|
91
|
+
name,
|
|
92
|
+
'aria-label': ariaLabel
|
|
93
|
+
}) {
|
|
94
|
+
return ariaLabel ?? alt ?? utils.normalizeAvatarName(name);
|
|
95
|
+
}
|
|
96
|
+
function AvatarImage(t0) {
|
|
97
|
+
const $ = reactCompilerRuntime.c(22);
|
|
98
|
+
const {
|
|
99
|
+
size,
|
|
100
|
+
name,
|
|
101
|
+
image,
|
|
102
|
+
label,
|
|
103
|
+
"aria-hidden": ariaHidden
|
|
104
|
+
} = t0;
|
|
105
|
+
const imageSources = utils.getSources(image, size);
|
|
43
106
|
let t1;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
({
|
|
48
|
-
user,
|
|
49
|
-
avatarUrl,
|
|
50
|
-
size: t1,
|
|
51
|
-
className,
|
|
52
|
-
colorList: t2,
|
|
53
|
-
exceptionallySetClassName,
|
|
54
|
-
...props
|
|
55
|
-
} = t0);
|
|
56
|
-
$[0] = t0;
|
|
57
|
-
$[1] = avatarUrl;
|
|
58
|
-
$[2] = className;
|
|
59
|
-
$[3] = exceptionallySetClassName;
|
|
60
|
-
$[4] = props;
|
|
61
|
-
$[5] = t1;
|
|
62
|
-
$[6] = t2;
|
|
63
|
-
$[7] = user;
|
|
64
|
-
} else {
|
|
65
|
-
avatarUrl = $[1];
|
|
66
|
-
className = $[2];
|
|
67
|
-
exceptionallySetClassName = $[3];
|
|
68
|
-
props = $[4];
|
|
69
|
-
t1 = $[5];
|
|
70
|
-
t2 = $[6];
|
|
71
|
-
user = $[7];
|
|
72
|
-
}
|
|
73
|
-
const size = t1 === undefined ? "l" : t1;
|
|
74
|
-
const colorList = t2 === undefined ? AVATAR_COLORS : t2;
|
|
75
|
-
let t3;
|
|
76
|
-
if ($[8] !== user.email || $[9] !== user.name) {
|
|
77
|
-
t3 = utils.getInitials(user.name) || utils.getInitials(user.email);
|
|
78
|
-
$[8] = user.email;
|
|
79
|
-
$[9] = user.name;
|
|
80
|
-
$[10] = t3;
|
|
107
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
108
|
+
t1 = [];
|
|
109
|
+
$[0] = t1;
|
|
81
110
|
} else {
|
|
82
|
-
|
|
111
|
+
t1 = $[0];
|
|
83
112
|
}
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
let
|
|
87
|
-
if ($[
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
backgroundColor: colorList[utils.emailToIndex(user.email, colorList.length)]
|
|
93
|
-
};
|
|
94
|
-
$[11] = avatarUrl;
|
|
95
|
-
$[12] = colorList;
|
|
96
|
-
$[13] = user.email;
|
|
97
|
-
$[14] = t4;
|
|
113
|
+
const [failedImageSources, setFailedImageSources] = React__namespace.useState(t1);
|
|
114
|
+
const availableImageSources = utils.getAvailableImageSources(imageSources, failedImageSources);
|
|
115
|
+
let t2;
|
|
116
|
+
if ($[1] !== availableImageSources || $[2] !== name) {
|
|
117
|
+
t2 = availableImageSources ? "" : utils.getInitials(name);
|
|
118
|
+
$[1] = availableImageSources;
|
|
119
|
+
$[2] = name;
|
|
120
|
+
$[3] = t2;
|
|
98
121
|
} else {
|
|
99
|
-
|
|
122
|
+
t2 = $[3];
|
|
100
123
|
}
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
$[
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
124
|
+
const initials = t2;
|
|
125
|
+
const hasInitials = initials !== "";
|
|
126
|
+
if (availableImageSources) {
|
|
127
|
+
let t3;
|
|
128
|
+
if ($[4] !== availableImageSources || $[5] !== setFailedImageSources) {
|
|
129
|
+
t3 = event => {
|
|
130
|
+
const failedSource = getFailedImageSource(availableImageSources, event.currentTarget);
|
|
131
|
+
setFailedImageSources(currentFailedSources => currentFailedSources.includes(failedSource) ? currentFailedSources : [...currentFailedSources, failedSource]);
|
|
132
|
+
};
|
|
133
|
+
$[4] = availableImageSources;
|
|
134
|
+
$[5] = setFailedImageSources;
|
|
135
|
+
$[6] = t3;
|
|
136
|
+
} else {
|
|
137
|
+
t3 = $[6];
|
|
138
|
+
}
|
|
139
|
+
let t4;
|
|
140
|
+
if ($[7] !== ariaHidden || $[8] !== availableImageSources.sizes || $[9] !== availableImageSources.src || $[10] !== availableImageSources.srcSet || $[11] !== label || $[12] !== t3) {
|
|
141
|
+
t4 = /*#__PURE__*/React__namespace.createElement("img", {
|
|
142
|
+
className: avatar_module["default"].image,
|
|
143
|
+
src: availableImageSources.src,
|
|
144
|
+
srcSet: availableImageSources.srcSet,
|
|
145
|
+
sizes: availableImageSources.sizes,
|
|
146
|
+
alt: label,
|
|
147
|
+
"aria-hidden": ariaHidden,
|
|
148
|
+
onError: t3
|
|
149
|
+
});
|
|
150
|
+
$[7] = ariaHidden;
|
|
151
|
+
$[8] = availableImageSources.sizes;
|
|
152
|
+
$[9] = availableImageSources.src;
|
|
153
|
+
$[10] = availableImageSources.srcSet;
|
|
154
|
+
$[11] = label;
|
|
155
|
+
$[12] = t3;
|
|
156
|
+
$[13] = t4;
|
|
157
|
+
} else {
|
|
158
|
+
t4 = $[13];
|
|
159
|
+
}
|
|
160
|
+
return t4;
|
|
109
161
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
162
|
+
if (hasInitials) {
|
|
163
|
+
const t3 = avatar_module["default"][`meta-color-${utils.getAvatarMetaColorIndex(name)}`];
|
|
164
|
+
let t4;
|
|
165
|
+
if ($[14] !== t3) {
|
|
166
|
+
t4 = classNames__default["default"](avatar_module["default"].initials, t3);
|
|
167
|
+
$[14] = t3;
|
|
168
|
+
$[15] = t4;
|
|
169
|
+
} else {
|
|
170
|
+
t4 = $[15];
|
|
171
|
+
}
|
|
172
|
+
const t5 = label ? "img" : undefined;
|
|
173
|
+
let t6;
|
|
174
|
+
if ($[16] !== ariaHidden || $[17] !== initials || $[18] !== label || $[19] !== t4 || $[20] !== t5) {
|
|
175
|
+
t6 = /*#__PURE__*/React__namespace.createElement("div", {
|
|
176
|
+
className: t4,
|
|
177
|
+
role: t5,
|
|
178
|
+
"aria-label": label,
|
|
179
|
+
"aria-hidden": ariaHidden
|
|
180
|
+
}, initials);
|
|
181
|
+
$[16] = ariaHidden;
|
|
182
|
+
$[17] = initials;
|
|
183
|
+
$[18] = label;
|
|
184
|
+
$[19] = t4;
|
|
185
|
+
$[20] = t5;
|
|
186
|
+
$[21] = t6;
|
|
187
|
+
} else {
|
|
188
|
+
t6 = $[21];
|
|
189
|
+
}
|
|
190
|
+
return t6;
|
|
120
191
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
$[22] = style;
|
|
129
|
-
$[23] = t6;
|
|
130
|
-
$[24] = userInitials;
|
|
131
|
-
$[25] = t7;
|
|
132
|
-
} else {
|
|
133
|
-
t7 = $[25];
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
function getAbsoluteImageSource(src, image) {
|
|
195
|
+
try {
|
|
196
|
+
return new URL(src, image.ownerDocument.baseURI).href;
|
|
197
|
+
} catch {
|
|
198
|
+
return src;
|
|
134
199
|
}
|
|
135
|
-
return t7;
|
|
136
200
|
}
|
|
137
|
-
|
|
201
|
+
function getFailedImageSource(imageProps, image) {
|
|
202
|
+
const failedSrc = image.currentSrc || image.src || imageProps.src;
|
|
203
|
+
const matchingSource = imageProps.sources?.find(({
|
|
204
|
+
src
|
|
205
|
+
}) => src === failedSrc || getAbsoluteImageSource(src, image) === failedSrc);
|
|
206
|
+
return matchingSource?.src ?? imageProps.src;
|
|
207
|
+
}
|
|
138
208
|
|
|
139
209
|
exports.Avatar = Avatar;
|
|
140
210
|
//# sourceMappingURL=avatar.js.map
|
package/lib/avatar/avatar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar.js","sources":["../../src/avatar/avatar.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { Box } from '../box'\nimport { getClassNames } from '../utils/responsive-props'\n\nimport { emailToIndex, getInitials } from './utils'\n\nimport styles from './avatar.module.css'\n\nimport type { ObfuscatedClassName } from '../utils/common-types'\nimport type { ResponsiveProp } from '../utils/responsive-props'\n\nconst AVATAR_COLORS = [\n '#fcc652',\n '#e9952c',\n '#e16b2d',\n '#d84b40',\n '#e8435a',\n '#e5198a',\n '#ad3889',\n '#86389c',\n '#a8a8a8',\n '#98be2f',\n '#5d9d50',\n '#5f9f85',\n '#5bbcb6',\n '#32a3bf',\n '#2bafeb',\n '#2d88c3',\n '#3863cc',\n '#5e5e5e',\n]\n\ntype AvatarSize = 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl'\n\ntype Props = ObfuscatedClassName & {\n /** @deprecated Please use `exceptionallySetClassName` */\n className?: string\n /** @deprecated */\n colorList?: string[]\n size?: ResponsiveProp<AvatarSize>\n avatarUrl?: string\n user: { name?: string; email: string }\n}\n\nfunction Avatar({\n user,\n avatarUrl,\n size = 'l',\n className,\n colorList = AVATAR_COLORS,\n exceptionallySetClassName,\n ...props\n}: Props) {\n const userInitials = getInitials(user.name) || getInitials(user.email)\n const avatarSize = size ? size : 'l'\n\n const style = avatarUrl\n ? {\n backgroundImage: `url(${avatarUrl})`,\n textIndent: '-9999px', // hide the initials\n }\n : {\n backgroundColor: colorList[emailToIndex(user.email, colorList.length)],\n }\n\n const sizeClassName = getClassNames(styles, 'size', avatarSize)\n\n return (\n <Box\n className={[className, styles.avatar, sizeClassName, exceptionallySetClassName]}\n style={style}\n {...props}\n >\n {userInitials}\n </Box>\n )\n}\nAvatar.displayName = 'Avatar'\n\nexport { Avatar }\n"],"names":["AVATAR_COLORS","Avatar","t0","$","_c","avatarUrl","className","exceptionallySetClassName","props","t1","t2","user","size","colorList","undefined","t3","email","name","getInitials","userInitials","avatarSize","t4","backgroundImage","textIndent","backgroundColor","emailToIndex","length","style","t5","getClassNames","styles","sizeClassName","t6","avatar","t7","React","createElement","Box","_extends","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAMA,aAAa,GAAG,CAClB,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,CACZ,CAAA;AAcD,SAAAC,OAAAC,EAAA,EAAA;EAAA,MAAAC,CAAA,GAAAC,sBAAA,CAAA,EAAA,CAAA,CAAA;AAAA,EAAA,IAAAC,SAAA,CAAA;AAAA,EAAA,IAAAC,SAAA,CAAA;AAAA,EAAA,IAAAC,yBAAA,CAAA;AAAA,EAAA,IAAAC,KAAA,CAAA;AAAA,EAAA,IAAAC,EAAA,CAAA;AAAA,EAAA,IAAAC,EAAA,CAAA;AAAA,EAAA,IAAAC,IAAA,CAAA;EAAA,IAAAR,CAAA,QAAAD,EAAA,EAAA;AAAgB,IAAA,CAAA;MAAAS,IAAA;MAAAN,SAAA;AAAAO,MAAAA,IAAA,EAAAH,EAAA;MAAAH,SAAA;AAAAO,MAAAA,SAAA,EAAAH,EAAA;MAAAH,yBAAA;MAAA,GAAAC,KAAAA;AAAA,KAAA,GAAAN,EAQR,EAAA;AAAAC,IAAAA,CAAA,MAAAD,EAAA,CAAA;AAAAC,IAAAA,CAAA,MAAAE,SAAA,CAAA;AAAAF,IAAAA,CAAA,MAAAG,SAAA,CAAA;AAAAH,IAAAA,CAAA,MAAAI,yBAAA,CAAA;AAAAJ,IAAAA,CAAA,MAAAK,KAAA,CAAA;AAAAL,IAAAA,CAAA,MAAAM,EAAA,CAAA;AAAAN,IAAAA,CAAA,MAAAO,EAAA,CAAA;AAAAP,IAAAA,CAAA,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A;AAAA,EAAA,OANN+B,EAMM,CAAA;AAAA,CAAA;AAGdjC,MAAM,CAACsC,WAAW,GAAG,QAAQ;;;;"}
|
|
1
|
+
{"version":3,"file":"avatar.js","sources":["../../src/avatar/avatar.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport classNames from 'classnames'\n\nimport { Box } from '../box'\nimport { polymorphicComponent } from '../utils/polymorphism'\n\nimport {\n getAvailableImageSources,\n getAvatarImageIdentityKey,\n getAvatarMetaColorIndex,\n getInitials,\n getSources,\n normalizeAvatarName,\n} from './utils'\n\nimport styles from './avatar.module.css'\n\nimport type { ObfuscatedClassName } from '../utils/common-types'\nimport type { PolymorphicComponentProps } from '../utils/polymorphism'\nimport type { AvatarImage as AvatarImageProp, AvatarShape, AvatarSize, ImageSources } from './utils'\n\n/**\n * Props for the `Avatar` component.\n */\ntype AvatarOwnProps = ObfuscatedClassName & {\n /**\n * The rendered avatar size, in CSS pixels.\n */\n size: AvatarSize\n\n /**\n * The avatar shape.\n *\n * @default 'circle'\n */\n shape?: AvatarShape\n\n /**\n * The display name represented by the avatar.\n *\n * Used as the default accessible label, to generate fallback initials, and\n * to assign the deterministic background color when rendering initials.\n */\n name?: string\n\n /**\n * The avatar image.\n *\n * Pass a string for a single image URL, or a source map keyed by intrinsic\n * image width. Source maps render as native `srcSet`/`sizes` hints, with\n * the largest valid source used as the fallback `src`.\n */\n image?: AvatarImageProp\n\n /**\n * Accessible text for the avatar image.\n *\n * Defaults to `name`. Pass an empty string when the avatar is decorative.\n */\n alt?: string\n\n /**\n * Test identifier applied to the avatar root element.\n */\n 'data-testid'?: string\n\n /**\n * Avatar owns its root sizing styles. Use `exceptionallySetClassName` for the styling escape\n * hatch.\n */\n style?: never\n}\n\ntype AvatarProps<ComponentType extends React.ElementType = 'div'> = PolymorphicComponentProps<\n ComponentType,\n AvatarOwnProps,\n 'omitClassName'\n>\n\n/**\n * Displays an avatar from an image URL, a source map keyed by intrinsic\n * image width, or initials derived from the provided name (with a background\n * color).\n */\nconst Avatar = polymorphicComponent<'div', AvatarOwnProps, 'omitClassName'>(function Avatar(\n {\n as,\n size,\n shape = 'circle',\n name,\n image,\n alt,\n exceptionallySetClassName,\n 'data-testid': testId,\n 'aria-hidden': ariaHidden,\n 'aria-label': ariaLabel,\n ...restProps\n },\n ref,\n) {\n const label = getAvatarLabel({ alt, name, 'aria-label': ariaLabel })\n const isDecorative = Boolean(ariaHidden ?? label === '')\n\n return (\n <Box\n as={as}\n ref={ref}\n className={classNames(\n styles.avatar,\n styles[`size-${size}`],\n styles[`shape-${shape}`],\n exceptionallySetClassName,\n )}\n data-testid={testId}\n display=\"inlineFlex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n flexShrink={0}\n overflow=\"hidden\"\n textAlign=\"center\"\n {...restProps}\n >\n <AvatarImage\n // Allows `AvatarImage` to remount when the image map changes,\n // which resets error states without replacing the avatar root.\n key={getAvatarImageIdentityKey(image)}\n size={size}\n name={name}\n image={image}\n label={label}\n aria-hidden={isDecorative}\n />\n </Box>\n )\n})\n\nfunction getAvatarLabel({\n alt,\n name,\n 'aria-label': ariaLabel,\n}: Pick<AvatarProps, 'alt' | 'name' | 'aria-label'>) {\n return ariaLabel ?? alt ?? normalizeAvatarName(name)\n}\n\ntype AvatarImageProps = {\n size: AvatarSize\n name?: string\n image?: AvatarImageProp\n label?: string\n 'aria-hidden'?: boolean\n}\n\nfunction AvatarImage({ size, name, image, label, 'aria-hidden': ariaHidden }: AvatarImageProps) {\n const imageSources = getSources(image, size)\n const [failedImageSources, setFailedImageSources] = React.useState<string[]>([])\n const availableImageSources = getAvailableImageSources(imageSources, failedImageSources)\n const initials = availableImageSources ? '' : getInitials(name)\n const hasInitials = initials !== ''\n\n if (availableImageSources) {\n return (\n <img\n className={styles.image}\n src={availableImageSources.src}\n srcSet={availableImageSources.srcSet}\n sizes={availableImageSources.sizes}\n alt={label}\n aria-hidden={ariaHidden}\n onError={(event) => {\n const failedSource = getFailedImageSource(\n availableImageSources,\n event.currentTarget,\n )\n\n setFailedImageSources((currentFailedSources) =>\n currentFailedSources.includes(failedSource)\n ? currentFailedSources\n : [...currentFailedSources, failedSource],\n )\n }}\n />\n )\n }\n if (hasInitials) {\n return (\n <div\n className={classNames(\n styles.initials,\n styles[`meta-color-${getAvatarMetaColorIndex(name)}`],\n )}\n role={label ? 'img' : undefined}\n aria-label={label}\n aria-hidden={ariaHidden}\n >\n {initials}\n </div>\n )\n }\n\n return null\n}\n\nfunction getAbsoluteImageSource(src: string, image: HTMLImageElement) {\n try {\n return new URL(src, image.ownerDocument.baseURI).href\n } catch {\n return src\n }\n}\n\nfunction getFailedImageSource(imageProps: ImageSources, image: HTMLImageElement) {\n const failedSrc = image.currentSrc || image.src || imageProps.src\n const matchingSource = imageProps.sources?.find(\n ({ src }) => src === failedSrc || getAbsoluteImageSource(src, image) === failedSrc,\n )\n\n return matchingSource?.src ?? imageProps.src\n}\n\nexport { Avatar }\nexport type { AvatarProps }\nexport type { AvatarImage, AvatarShape, AvatarSize } from './utils'\n"],"names":["Avatar","polymorphicComponent","as","size","shape","name","image","alt","exceptionallySetClassName","testId","ariaHidden","ariaLabel","restProps","ref","label","getAvatarLabel","isDecorative","Boolean","React","createElement","Box","_extends","className","classNames","styles","avatar","display","alignItems","justifyContent","flexShrink","overflow","textAlign","AvatarImage","key","getAvatarImageIdentityKey","normalizeAvatarName","t0","$","_c","imageSources","getSources","t1","Symbol","for","failedImageSources","setFailedImageSources","useState","availableImageSources","getAvailableImageSources","t2","getInitials","initials","hasInitials","t3","event","failedSource","getFailedImageSource","currentTarget","currentFailedSources","includes","t4","sizes","src","srcSet","onError","getAvatarMetaColorIndex","t5","undefined","t6","role","getAbsoluteImageSource","URL","ownerDocument","baseURI","href","imageProps","failedSrc","currentSrc","matchingSource","sources","find"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA;AACA;AACA;;AAwDA;AACA;AACA;AACA;AACA;AACA,MAAMA,MAAM,GAAGC,iCA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A;AAAA,KAAA,MAAA;AAAAA,MAAAA,EAAA,GAAA/B,CAAA,CAAA,EAAA,CAAA,CAAA;AAAA,KAAA;AAAA,IAAA,OAVN+B,EAUM,CAAA;AAAA,GAAA;AAEb,EAAA,OAEM,IAAI,CAAA;AAAA,CAAA;AAGf,SAASE,sBAAsBA,CAACR,GAAW,EAAExD,KAAuB,EAAE;EAClE,IAAI;AACA,IAAA,OAAO,IAAIiE,GAAG,CAACT,GAAG,EAAExD,KAAK,CAACkE,aAAa,CAACC,OAAO,CAAC,CAACC,IAAI,CAAA;AACzD,GAAC,CAAC,MAAM;AACJ,IAAA,OAAOZ,GAAG,CAAA;AACd,GAAA;AACJ,CAAA;AAEA,SAASN,oBAAoBA,CAACmB,UAAwB,EAAErE,KAAuB,EAAE;AAC7E,EAAA,MAAMsE,SAAS,GAAGtE,KAAK,CAACuE,UAAU,IAAIvE,KAAK,CAACwD,GAAG,IAAIa,UAAU,CAACb,GAAG,CAAA;EACjE,MAAMgB,cAAc,GAAGH,UAAU,CAACI,OAAO,EAAEC,IAAI,CAC3C,CAAC;AAAElB,IAAAA,GAAAA;AAAI,GAAC,KAAKA,GAAG,KAAKc,SAAS,IAAIN,sBAAsB,CAACR,GAAG,EAAExD,KAAK,CAAC,KAAKsE,SAC7E,CAAC,CAAA;AAED,EAAA,OAAOE,cAAc,EAAEhB,GAAG,IAAIa,UAAU,CAACb,GAAG,CAAA;AAChD;;;;"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var modules_08f3eeac = {"avatar":"
|
|
5
|
+
var modules_08f3eeac = {"avatar":"acf9ee3d","size-80":"_5b32f21b","size-72":"_5dd2ceae","size-62":"_0737423f","size-50":"_47744c53","size-40":"_087775aa","size-36":"_02c89bce","size-30":"_3ed61ce0","size-28":"c9fa2651","size-24":"_89506d0e","size-20":"d7ab9fd7","size-18":"_32fef877","size-16":"_8962c0a0","size-12":"a06fa349","initials":"_80b6bfbf","meta-color-0":"_64da0562","meta-color-1":"ee7c29c0","meta-color-2":"_70215fb1","meta-color-3":"_488b23cd","meta-color-4":"f6b3e824","meta-color-5":"_88b828ae","meta-color-6":"f931ad92","meta-color-7":"_504e515a","meta-color-8":"_277cc6cd","meta-color-9":"db85100e","meta-color-10":"c76af5ed","meta-color-11":"ab7368dc","meta-color-12":"c2a85a75","meta-color-13":"_0e942ae0","meta-color-14":"_2f79016f","meta-color-15":"_118f815d","meta-color-16":"_6e5574e6","meta-color-17":"_49d688e7","meta-color-18":"d5233bf3","meta-color-19":"_710699d5","shape-circle":"_2b4e8069","shape-rounded":"_28fdd710","image":"bda7eadb"};
|
|
6
6
|
|
|
7
7
|
exports["default"] = modules_08f3eeac;
|
|
8
8
|
//# sourceMappingURL=avatar.module.css.js.map
|
package/lib/avatar/utils.d.ts
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
declare const AVATAR_SIZES: readonly [80, 72, 62, 50, 40, 36, 30, 28, 24, 20, 18, 16, 12];
|
|
2
|
+
/**
|
|
3
|
+
* Supported avatar sizes, in CSS pixels.
|
|
4
|
+
*/
|
|
5
|
+
type AvatarSize = (typeof AVATAR_SIZES)[number];
|
|
6
|
+
/**
|
|
7
|
+
* Supported avatar clipping shapes.
|
|
8
|
+
*/
|
|
9
|
+
type AvatarShape = 'circle' | 'rounded';
|
|
10
|
+
/**
|
|
11
|
+
* Avatar image source.
|
|
12
|
+
*
|
|
13
|
+
* Use a string for a single image URL, or a source map keyed by intrinsic image width. Source maps
|
|
14
|
+
* are converted to native `srcSet` width descriptors.
|
|
15
|
+
*/
|
|
16
|
+
type AvatarImage = string | Record<number, string>;
|
|
17
|
+
type AvatarImageSource = {
|
|
18
|
+
sourceSize: number;
|
|
19
|
+
src: string;
|
|
20
|
+
};
|
|
21
|
+
type ImageSources = {
|
|
22
|
+
src: string;
|
|
23
|
+
srcSet?: string;
|
|
24
|
+
sizes?: string;
|
|
25
|
+
sources?: AvatarImageSource[];
|
|
26
|
+
};
|
|
27
|
+
declare const AVATAR_META_COLOR_COUNT = 20;
|
|
28
|
+
declare function normalizeAvatarName(name?: string): string;
|
|
29
|
+
declare function getInitials(name?: string): string;
|
|
30
|
+
declare function getSources(image: AvatarImage | undefined, size: AvatarSize): ImageSources | undefined;
|
|
31
|
+
declare function getAvatarImageIdentityKey(image?: AvatarImage): string;
|
|
32
|
+
declare function getAvailableImageSources(imageProps: ImageSources | undefined, failedSources: readonly string[]): ImageSources | undefined;
|
|
33
|
+
declare function getAvatarMetaColorIndex(name?: string): number;
|
|
34
|
+
export { AVATAR_META_COLOR_COUNT, AVATAR_SIZES, getAvailableImageSources, getAvatarImageIdentityKey, getAvatarMetaColorIndex, getInitials, getSources, normalizeAvatarName, };
|
|
35
|
+
export type { AvatarImage, AvatarImageSource, AvatarShape, AvatarSize, ImageSources };
|
package/lib/avatar/utils.js
CHANGED
|
@@ -2,28 +2,129 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Supported avatar sizes, in CSS pixels.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Supported avatar clipping shapes.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Avatar image source.
|
|
15
|
+
*
|
|
16
|
+
* Use a string for a single image URL, or a source map keyed by intrinsic image width. Source maps
|
|
17
|
+
* are converted to native `srcSet` width descriptors.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const AVATAR_META_COLOR_COUNT = 20;
|
|
21
|
+
const WHITESPACE_REGEXP = new RegExp('\\p{White_Space}+', 'gu');
|
|
22
|
+
const GRAPHEME_SEGMENTER = typeof Intl !== 'undefined' && 'Segmenter' in Intl ? new Intl.Segmenter('und', {
|
|
23
|
+
granularity: 'grapheme'
|
|
24
|
+
}) : undefined;
|
|
25
|
+
function normalizeAvatarName(name) {
|
|
26
|
+
return name?.normalize('NFC').trim().replace(WHITESPACE_REGEXP, ' ') ?? '';
|
|
27
|
+
}
|
|
28
|
+
function getGraphemeClusters(value) {
|
|
29
|
+
if (GRAPHEME_SEGMENTER) {
|
|
30
|
+
return Array.from(GRAPHEME_SEGMENTER.segment(value), ({
|
|
31
|
+
segment
|
|
32
|
+
}) => segment);
|
|
33
|
+
}
|
|
34
|
+
return Array.from(value);
|
|
35
|
+
}
|
|
36
|
+
function getInitialGrapheme(value) {
|
|
37
|
+
return getGraphemeClusters(value?.toUpperCase() ?? '')[0] ?? '';
|
|
38
|
+
}
|
|
5
39
|
function getInitials(name) {
|
|
6
|
-
|
|
40
|
+
const nameParts = normalizeAvatarName(name).split(' ').filter(Boolean);
|
|
41
|
+
if (nameParts.length === 0) {
|
|
7
42
|
return '';
|
|
8
43
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
44
|
+
if (nameParts.length === 1) {
|
|
45
|
+
return getGraphemeClusters(nameParts[0].toUpperCase()).slice(0, 2).join('');
|
|
46
|
+
}
|
|
47
|
+
return `${getInitialGrapheme(nameParts[0])}${getInitialGrapheme(nameParts[nameParts.length - 1])}`;
|
|
48
|
+
}
|
|
49
|
+
function getSortedImageSources(image) {
|
|
50
|
+
return Object.entries(image).map(([sourceSize, src]) => ({
|
|
51
|
+
sourceSize: Number(sourceSize),
|
|
52
|
+
src
|
|
53
|
+
})).filter(({
|
|
54
|
+
sourceSize,
|
|
55
|
+
src
|
|
56
|
+
}) => Number.isFinite(sourceSize) && sourceSize > 0 && src).sort((a, b) => a.sourceSize - b.sourceSize);
|
|
57
|
+
}
|
|
58
|
+
function getImagePropsFromSources(sources, sizes) {
|
|
59
|
+
if (sources.length === 0) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
src: sources[sources.length - 1].src,
|
|
64
|
+
srcSet: sources.map(({
|
|
65
|
+
sourceSize,
|
|
66
|
+
src
|
|
67
|
+
}) => `${src} ${sourceSize}w`).join(', '),
|
|
68
|
+
sizes,
|
|
69
|
+
sources
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function getSources(image, size) {
|
|
73
|
+
if (!image) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
if (typeof image === 'string') {
|
|
77
|
+
return {
|
|
78
|
+
src: image
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const sources = getSortedImageSources(image);
|
|
82
|
+
return getImagePropsFromSources(sources, `${size}px`);
|
|
83
|
+
}
|
|
84
|
+
function getAvatarImageIdentityKey(image) {
|
|
85
|
+
if (!image) {
|
|
86
|
+
return 'fallback';
|
|
87
|
+
}
|
|
88
|
+
if (typeof image === 'string') {
|
|
89
|
+
return image;
|
|
90
|
+
}
|
|
91
|
+
const sources = getSortedImageSources(image);
|
|
92
|
+
if (sources.length === 0) {
|
|
93
|
+
return 'fallback';
|
|
18
94
|
}
|
|
19
|
-
return
|
|
95
|
+
return sources.map(({
|
|
96
|
+
sourceSize,
|
|
97
|
+
src
|
|
98
|
+
}) => `${sourceSize}:${src}`).join('|');
|
|
20
99
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
100
|
+
function getAvailableImageSources(imageProps, failedSources) {
|
|
101
|
+
if (!imageProps) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
if (failedSources.length === 0) {
|
|
105
|
+
return imageProps;
|
|
106
|
+
}
|
|
107
|
+
if (!imageProps.sources) {
|
|
108
|
+
return failedSources.includes(imageProps.src) ? undefined : imageProps;
|
|
109
|
+
}
|
|
110
|
+
return getImagePropsFromSources(imageProps.sources.filter(({
|
|
111
|
+
src
|
|
112
|
+
}) => !failedSources.includes(src)), imageProps.sizes);
|
|
113
|
+
}
|
|
114
|
+
function getAvatarMetaColorIndex(name) {
|
|
115
|
+
const normalizedName = normalizeAvatarName(name);
|
|
116
|
+
let hash = 0;
|
|
117
|
+
for (const char of normalizedName) {
|
|
118
|
+
hash = hash * 31 + (char.codePointAt(0) ?? 0) >>> 0;
|
|
119
|
+
}
|
|
120
|
+
return hash % AVATAR_META_COLOR_COUNT;
|
|
25
121
|
}
|
|
26
122
|
|
|
27
|
-
exports.
|
|
123
|
+
exports.AVATAR_META_COLOR_COUNT = AVATAR_META_COLOR_COUNT;
|
|
124
|
+
exports.getAvailableImageSources = getAvailableImageSources;
|
|
125
|
+
exports.getAvatarImageIdentityKey = getAvatarImageIdentityKey;
|
|
126
|
+
exports.getAvatarMetaColorIndex = getAvatarMetaColorIndex;
|
|
28
127
|
exports.getInitials = getInitials;
|
|
128
|
+
exports.getSources = getSources;
|
|
129
|
+
exports.normalizeAvatarName = normalizeAvatarName;
|
|
29
130
|
//# sourceMappingURL=utils.js.map
|
package/lib/avatar/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../src/avatar/utils.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../src/avatar/utils.ts"],"sourcesContent":["const AVATAR_SIZES = [80, 72, 62, 50, 40, 36, 30, 28, 24, 20, 18, 16, 12] as const\n\n/**\n * Supported avatar sizes, in CSS pixels.\n */\ntype AvatarSize = (typeof AVATAR_SIZES)[number]\n\n/**\n * Supported avatar clipping shapes.\n */\ntype AvatarShape = 'circle' | 'rounded'\n\n/**\n * Avatar image source.\n *\n * Use a string for a single image URL, or a source map keyed by intrinsic image width. Source maps\n * are converted to native `srcSet` width descriptors.\n */\ntype AvatarImage = string | Record<number, string>\n\ntype AvatarImageSource = {\n sourceSize: number\n src: string\n}\n\ntype ImageSources = {\n src: string\n srcSet?: string\n sizes?: string\n sources?: AvatarImageSource[]\n}\n\nconst AVATAR_META_COLOR_COUNT = 20\n\nconst WHITESPACE_REGEXP = new RegExp('\\\\p{White_Space}+', 'gu')\nconst GRAPHEME_SEGMENTER =\n typeof Intl !== 'undefined' && 'Segmenter' in Intl\n ? new Intl.Segmenter('und', { granularity: 'grapheme' })\n : undefined\n\nfunction normalizeAvatarName(name?: string) {\n return name?.normalize('NFC').trim().replace(WHITESPACE_REGEXP, ' ') ?? ''\n}\n\nfunction getGraphemeClusters(value: string) {\n if (GRAPHEME_SEGMENTER) {\n return Array.from(GRAPHEME_SEGMENTER.segment(value), ({ segment }) => segment)\n }\n\n return Array.from(value)\n}\n\nfunction getInitialGrapheme(value?: string) {\n return getGraphemeClusters(value?.toUpperCase() ?? '')[0] ?? ''\n}\n\nfunction getInitials(name?: string) {\n const nameParts = normalizeAvatarName(name).split(' ').filter(Boolean)\n\n if (nameParts.length === 0) {\n return ''\n }\n\n if (nameParts.length === 1) {\n return getGraphemeClusters(nameParts[0]!.toUpperCase()).slice(0, 2).join('')\n }\n\n return `${getInitialGrapheme(nameParts[0])}${getInitialGrapheme(nameParts[nameParts.length - 1])}`\n}\n\nfunction getSortedImageSources(image: Record<number, string>): AvatarImageSource[] {\n return Object.entries(image)\n .map(([sourceSize, src]) => ({ sourceSize: Number(sourceSize), src }))\n .filter(({ sourceSize, src }) => Number.isFinite(sourceSize) && sourceSize > 0 && src)\n .sort((a, b) => a.sourceSize - b.sourceSize)\n}\n\nfunction getImagePropsFromSources(\n sources: AvatarImageSource[],\n sizes?: string,\n): ImageSources | undefined {\n if (sources.length === 0) {\n return undefined\n }\n\n return {\n src: sources[sources.length - 1]!.src,\n srcSet: sources.map(({ sourceSize, src }) => `${src} ${sourceSize}w`).join(', '),\n sizes,\n sources,\n }\n}\n\nfunction getSources(image: AvatarImage | undefined, size: AvatarSize): ImageSources | undefined {\n if (!image) {\n return undefined\n }\n\n if (typeof image === 'string') {\n return { src: image }\n }\n\n const sources = getSortedImageSources(image)\n return getImagePropsFromSources(sources, `${size}px`)\n}\n\nfunction getAvatarImageIdentityKey(image?: AvatarImage) {\n if (!image) {\n return 'fallback'\n }\n\n if (typeof image === 'string') {\n return image\n }\n\n const sources = getSortedImageSources(image)\n if (sources.length === 0) {\n return 'fallback'\n }\n\n return sources.map(({ sourceSize, src }) => `${sourceSize}:${src}`).join('|')\n}\n\nfunction getAvailableImageSources(\n imageProps: ImageSources | undefined,\n failedSources: readonly string[],\n) {\n if (!imageProps) {\n return undefined\n }\n\n if (failedSources.length === 0) {\n return imageProps\n }\n\n if (!imageProps.sources) {\n return failedSources.includes(imageProps.src) ? undefined : imageProps\n }\n\n return getImagePropsFromSources(\n imageProps.sources.filter(({ src }) => !failedSources.includes(src)),\n imageProps.sizes,\n )\n}\n\nfunction getAvatarMetaColorIndex(name?: string) {\n const normalizedName = normalizeAvatarName(name)\n let hash = 0\n\n for (const char of normalizedName) {\n hash = (hash * 31 + (char.codePointAt(0) ?? 0)) >>> 0\n }\n\n return hash % AVATAR_META_COLOR_COUNT\n}\n\nexport {\n AVATAR_META_COLOR_COUNT,\n AVATAR_SIZES,\n getAvailableImageSources,\n getAvatarImageIdentityKey,\n getAvatarMetaColorIndex,\n getInitials,\n getSources,\n normalizeAvatarName,\n}\nexport type { AvatarImage, AvatarImageSource, AvatarShape, AvatarSize, ImageSources }\n"],"names":["AVATAR_META_COLOR_COUNT","WHITESPACE_REGEXP","RegExp","GRAPHEME_SEGMENTER","Intl","Segmenter","granularity","undefined","normalizeAvatarName","name","normalize","trim","replace","getGraphemeClusters","value","Array","from","segment","getInitialGrapheme","toUpperCase","getInitials","nameParts","split","filter","Boolean","length","slice","join","getSortedImageSources","image","Object","entries","map","sourceSize","src","Number","isFinite","sort","a","b","getImagePropsFromSources","sources","sizes","srcSet","getSources","size","getAvatarImageIdentityKey","getAvailableImageSources","imageProps","failedSources","includes","getAvatarMetaColorIndex","normalizedName","hash","char","codePointAt"],"mappings":";;;;AAEA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAC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