@giteeteam/apps-team-components 1.11.18-alpha.1 → 1.11.19

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.
@@ -5,7 +5,6 @@ interface UserAvatarProps {
5
5
  avatar?: {
6
6
  url?: string;
7
7
  };
8
- bosKey?: string;
9
8
  username?: string;
10
9
  name?: string;
11
10
  nickname?: string;
@@ -1,38 +1,15 @@
1
1
  import { jsx } from '@emotion/react/jsx-runtime';
2
- import React__default, { useState, useMemo, useEffect } from 'react';
2
+ import React__default, { useMemo } from 'react';
3
3
  import { ClassNames } from '@emotion/react';
4
- import useCurrentWorkspace from '../../../lib/hooks/useCurrentWorkspace.js';
5
4
  import { getNameBadge, getBackgroundColor } from '../utils.js';
6
5
  import { avatarItemStyle, avatarStyle, defaultAvatarStyle } from './style/index.js';
7
6
 
8
- const imgInAvatarStyle = `
9
- display: block;
10
- width: 100%;
11
- height: 100%;
12
- object-fit: contain;
13
- border-radius: 50%;
14
- `;
15
7
  const UserAvatar = React__default.memo(({ user, className }) => {
16
- const { workspaceKey } = useCurrentWorkspace();
17
- const [imageLoadFailed, setImageLoadFailed] = useState(false);
18
- const avatarUrl = useMemo(() => {
19
- var _a, _b, _c, _d;
20
- const url = (_a = user === null || user === void 0 ? void 0 : user.avatar) === null || _a === void 0 ? void 0 : _a.url;
21
- if (url)
22
- return url;
23
- const bosKey = (_d = (_c = (_b = user === null || user === void 0 ? void 0 : user.bosKey) === null || _b === void 0 ? void 0 : _b.trim) === null || _c === void 0 ? void 0 : _c.call(_b)) !== null && _d !== void 0 ? _d : user === null || user === void 0 ? void 0 : user.bosKey;
24
- if (!workspaceKey || !bosKey)
25
- return undefined;
26
- return `/api/one/${workspaceKey}/rest/v1/companies/${workspaceKey}/users/logo/picture?url=${encodeURIComponent(bosKey)}`;
27
- }, [user, workspaceKey]);
28
- useEffect(() => {
29
- setImageLoadFailed(false);
30
- }, [avatarUrl]);
8
+ const avatarUrl = useMemo(() => { var _a; return (_a = user === null || user === void 0 ? void 0 : user.avatar) === null || _a === void 0 ? void 0 : _a.url; }, [user]);
31
9
  const displayName = useMemo(() => (user === null || user === void 0 ? void 0 : user.name) || (user === null || user === void 0 ? void 0 : user.nickname) || (user === null || user === void 0 ? void 0 : user.username), [user]);
32
10
  const userBadge = useMemo(() => getNameBadge(displayName), [displayName]);
33
- const showImage = Boolean(avatarUrl) && !imageLoadFailed;
34
11
  return (jsx(ClassNames, { children: ({ cx, css }) => {
35
- return showImage ? (jsx("span", { className: cx('avatar-item', css(avatarItemStyle), css(avatarStyle), css(className)), style: { overflow: 'hidden' }, children: jsx("img", { src: avatarUrl, alt: "", decoding: "async", className: cx(css(imgInAvatarStyle)), onError: () => setImageLoadFailed(true) }) })) : (jsx("span", { className: cx('avatar-item', css(avatarItemStyle), css(defaultAvatarStyle), css(className)), style: getBackgroundColor(userBadge), children: userBadge }));
12
+ return avatarUrl ? (jsx("span", { className: cx('avatar-item', css(avatarItemStyle), css(avatarStyle), css(className)), style: { backgroundImage: `url(${avatarUrl})` } })) : (jsx("span", { className: cx('avatar-item', css(avatarItemStyle), css(defaultAvatarStyle), css(className)), style: getBackgroundColor(userBadge), children: userBadge }));
36
13
  } }));
37
14
  });
38
15
  UserAvatar.displayName = 'UserAvatar';
@@ -13,6 +13,5 @@ export type UserValueOption = {
13
13
  deleted: boolean;
14
14
  enabled: boolean;
15
15
  email?: string;
16
- bosKey?: string | null;
17
16
  };
18
17
  export declare const userDataFormat: (user: UserValue) => UserValueOption;
@@ -22,7 +22,7 @@ const generateUserDisplayName = (user, onlyNickname = false) => {
22
22
  return (user === null || user === void 0 ? void 0 : user.nickname) ? `${user === null || user === void 0 ? void 0 : user.nickname}${displaySuffix}` : user === null || user === void 0 ? void 0 : user.username;
23
23
  };
24
24
  const userDataFormat = (user) => {
25
- var _a, _b;
25
+ var _a;
26
26
  return ({
27
27
  label: generateUserDisplayName(user),
28
28
  value: (_a = user.objectId) !== null && _a !== void 0 ? _a : user.value,
@@ -31,7 +31,6 @@ const userDataFormat = (user) => {
31
31
  deleted: user.deleted,
32
32
  enabled: user.enabled,
33
33
  email: user.email,
34
- bosKey: (_b = user.bosKey) !== null && _b !== void 0 ? _b : null,
35
34
  });
36
35
  };
37
36
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giteeteam/apps-team-components",
3
- "version": "1.11.18-alpha.1",
3
+ "version": "1.11.19",
4
4
  "description": "Gitee team components",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",