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

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';
@@ -0,0 +1,6 @@
1
+ declare const _default: import("react").NamedExoticComponent<{
2
+ itemValues?: {
3
+ commentCount?: number;
4
+ };
5
+ }>;
6
+ export default _default;
@@ -0,0 +1,29 @@
1
+ import { jsxs, jsx } from '@emotion/react/jsx-runtime';
2
+ import { memo } from 'react';
3
+ import { css } from '@emotion/react';
4
+ import useI18n from '../../../lib/hooks/useI18n.js';
5
+ import { Icons } from '../../../icons/index.js';
6
+
7
+ const CommentReadViewStyle = css `
8
+ display: inline-flex;
9
+ align-items: center;
10
+ &:hover {
11
+ cursor: pointer;
12
+ color: var(--color-brand-6);
13
+ }
14
+
15
+ &.add-comment {
16
+ color: var(--color-gray-7);
17
+ }
18
+ `;
19
+ const CommentReadView = props => {
20
+ const { itemValues } = props;
21
+ const { t } = useI18n();
22
+ const commentCount = (itemValues === null || itemValues === void 0 ? void 0 : itemValues.commentCount) || 0;
23
+ const hasComment = commentCount > 0;
24
+ return (jsxs("span", { css: CommentReadViewStyle, className: hasComment ? '' : 'add-comment', children: [jsx(Icons.Comment, {}), jsx("span", { style: { marginLeft: '8px' }, children: hasComment ? t('fields.comment.count', { count: commentCount }) : t('fields.comment.add') })] }));
25
+ };
26
+ CommentReadView.displayName = 'CommentReadView';
27
+ var CommentReadView$1 = memo(CommentReadView);
28
+
29
+ export { CommentReadView$1 as default };
@@ -6,6 +6,7 @@ import BaseLineItemVersionReadView from '../fields/baseline-item-version/ReadVie
6
6
  import BindWorkspaceReadView from '../fields/bind-workspace/ReadView.js';
7
7
  import Cascade from '../fields/cascade/ReadView.js';
8
8
  import CheckboxReadView from '../fields/checkbox/ReadView.js';
9
+ import CommentReadView from '../fields/comment/ReadView.js';
9
10
  import CreatedAtReadView from '../fields/created-at/ReadView.js';
10
11
  import CreatedByReadView from '../fields/created-by/ReadView.js';
11
12
  import DataQuoteReadView from '../fields/data-quote/ReadView.js';
@@ -79,6 +80,7 @@ const getStandardReadComponents = () => {
79
80
  [FIELD_TYPE_KEY_MAPPINGS.Workspace]: WorkspaceReadView,
80
81
  [FIELD_TYPE_KEY_MAPPINGS.ItemLinkedStatistics]: TextReadView,
81
82
  [FIELD_TYPE_KEY_MAPPINGS.Actors]: ActorReadView,
83
+ [FIELD_TYPE_KEY_MAPPINGS.Comment]: CommentReadView,
82
84
  };
83
85
  return standardReadComponents;
84
86
  };
@@ -307,7 +307,7 @@ const CustomIconFont = React__default.memo(props => {
307
307
  CustomIconFont.displayName = 'CustomIconFont';
308
308
  const SingleColorIcon = ({ type, ...props }) => {
309
309
  const { antPrefix } = useAntdConfig();
310
- return (jsx(ClassNames, { children: ({ css, cx }) => (jsx("i", { ...props, className: cx('icon', css(proximaSingleColor(antPrefix)), `proxima-single-color-${type}`, props.className) })) }));
310
+ return (jsx(ClassNames, { children: ({ css, cx }) => (jsx("i", { ...props, className: cx('icon', css(proximaSingleColor(antPrefix)), 'proxima-single-color', `proxima-single-color-${type}`, props.className) })) }));
311
311
  };
312
312
  const Icons = [...MULTI_COLOR_KEYS, ...SIMPLE_COLOR_KEYS, ...Object.keys(ROTATE_ICONS)].reduce((res, key) => {
313
313
  res[key] = ({ className, ...props }) => {
@@ -1,4 +1,5 @@
1
1
  const proximaSingleColor = (antPrefix = 'ant') => `
2
+ position: static; /** 防止icon被其他产品模块影响 */
2
3
  display: inline-block;
3
4
  width: 1em;
4
5
  height: 1em;
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export { default as AncestorReadView } from './components/fields/ancestor/ReadVi
8
8
  export { default as AssigneeReadView } from './components/fields/assignee/ReadView';
9
9
  export { default as BindWorkspaceReadView } from './components/fields/bind-workspace/ReadView';
10
10
  export { default as CheckboxReadView } from './components/fields/checkbox/ReadView';
11
+ export { default as CommentReadView } from './components/fields/comment/ReadView';
11
12
  export { default as CreatedAtReadView } from './components/fields/created-at/ReadView';
12
13
  export { default as CreatedByReadView } from './components/fields/created-by/ReadView';
13
14
  export { default as DataQuoteReadView } from './components/fields/data-quote/ReadView';
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ export { default as AncestorReadView } from './components/fields/ancestor/ReadVi
8
8
  export { default as AssigneeReadView } from './components/fields/assignee/ReadView.js';
9
9
  export { default as BindWorkspaceReadView } from './components/fields/bind-workspace/ReadView.js';
10
10
  export { default as CheckboxReadView } from './components/fields/checkbox/ReadView.js';
11
+ export { default as CommentReadView } from './components/fields/comment/ReadView.js';
11
12
  export { default as CreatedAtReadView } from './components/fields/created-at/ReadView.js';
12
13
  export { default as CreatedByReadView } from './components/fields/created-by/ReadView.js';
13
14
  export { default as DataQuoteReadView } from './components/fields/data-quote/ReadView.js';
@@ -51,6 +51,7 @@ export declare const FIELD_TYPE_KEY_MAPPINGS: {
51
51
  Editor: string;
52
52
  Formula: string;
53
53
  Annex: string;
54
+ Comment: string;
54
55
  File: string;
55
56
  Tag: string;
56
57
  DataQuote: string;
@@ -50,6 +50,7 @@ const FIELD_TYPE_KEY_MAPPINGS = {
50
50
  Editor: 'Editor',
51
51
  Formula: 'Formula',
52
52
  Annex: 'Annex',
53
+ Comment: 'Comment',
53
54
  File: 'File',
54
55
  Tag: 'Tag',
55
56
  DataQuote: 'DataQuote',
@@ -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
 
@@ -10,6 +10,8 @@ export declare const en: {
10
10
  'date.week': string;
11
11
  'date.month': string;
12
12
  'date.year': string;
13
+ 'fields.comment.count': string;
14
+ 'fields.comment.add': string;
13
15
  'pages.fields.default.toWorkspacePage': string;
14
16
  'pages.fields.default.onlyWorkspace': string;
15
17
  'pages.fields.default.getImageError': string;
@@ -81,6 +83,8 @@ export declare const zh: {
81
83
  'date.week': string;
82
84
  'date.month': string;
83
85
  'date.year': string;
86
+ 'fields.comment.count': string;
87
+ 'fields.comment.add': string;
84
88
  'pages.fields.default.toWorkspacePage': string;
85
89
  'pages.fields.default.onlyWorkspace': string;
86
90
  'pages.fields.default.getImageError': string;
@@ -152,6 +156,8 @@ export declare const ru: {
152
156
  'date.week': string;
153
157
  'date.month': string;
154
158
  'date.year': string;
159
+ 'fields.comment.count': string;
160
+ 'fields.comment.add': string;
155
161
  'pages.fields.default.toWorkspacePage': string;
156
162
  'pages.fields.default.onlyWorkspace': string;
157
163
  'pages.fields.default.getImageError': string;
@@ -10,6 +10,8 @@ const en = {
10
10
  'date.week': 'Week',
11
11
  'date.month': 'Month',
12
12
  'date.year': 'Year',
13
+ 'fields.comment.count': '{{count}} comment(s)',
14
+ 'fields.comment.add': 'Add comment',
13
15
  'pages.fields.default.toWorkspacePage': 'Click to enter the workspace',
14
16
  'pages.fields.default.onlyWorkspace': 'Current Workspace',
15
17
  'pages.fields.default.getImageError': 'Image acquisition failure',
@@ -81,6 +83,8 @@ const zh = {
81
83
  'date.week': '周',
82
84
  'date.month': '月',
83
85
  'date.year': '年',
86
+ 'fields.comment.count': '{{count}} 条评论',
87
+ 'fields.comment.add': '添加评论',
84
88
  'pages.fields.default.toWorkspacePage': '点击进入空间',
85
89
  'pages.fields.default.onlyWorkspace': '只显示当前空间的{{name}}',
86
90
  'pages.fields.default.getImageError': '图片获取失败',
@@ -152,6 +156,8 @@ const ru = {
152
156
  'date.week': 'Неделя',
153
157
  'date.month': 'Месяц',
154
158
  'date.year': 'Год',
159
+ 'fields.comment.count': '{{count}} комментариев',
160
+ 'fields.comment.add': 'Добавить комментарий',
155
161
  'pages.fields.default.toWorkspacePage': 'Нажмите, чтобы войти в рабочее пространство',
156
162
  'pages.fields.default.onlyWorkspace': 'Current Workspace',
157
163
  'pages.fields.default.getImageError': 'Не удалось получить изображение',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giteeteam/apps-team-components",
3
- "version": "1.11.18",
3
+ "version": "1.11.20-alpha.1",
4
4
  "description": "Gitee team components",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",