@giteeteam/apps-team-components 1.0.9 → 1.0.11

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.
@@ -1,10 +1,6 @@
1
- import { CSSProperties } from 'react';
2
- interface BaseOverflowTooltip {
3
- className?: string;
4
- title?: string;
5
- children: any;
1
+ /// <reference types="react" />
2
+ interface BaseOverflowTooltip extends React.HTMLAttributes<HTMLSpanElement> {
6
3
  maxline?: number;
7
- style?: CSSProperties;
8
4
  }
9
5
  declare const BaseOverflowTooltip: React.FC<BaseOverflowTooltip>;
10
6
  declare const _default: import("react").NamedExoticComponent<BaseOverflowTooltip>;
@@ -3,7 +3,7 @@ import { cloneElement, memo, useRef } from 'react';
3
3
  import { ClassNames } from '@emotion/react';
4
4
  import { getTooltipMaxlineStyle, tooltipOverflowStyle } from './style';
5
5
  const BaseOverflowTooltip = props => {
6
- const { className, title, children, maxline, style } = props;
6
+ const { className, title, children, maxline = 1, style, onClick } = props;
7
7
  const elRef = useRef();
8
8
  if (!children) {
9
9
  return null;
@@ -15,12 +15,9 @@ const BaseOverflowTooltip = props => {
15
15
  className: cx(css(tooltipOverflowStyle), css(getTooltipMaxlineStyle(maxline)), className),
16
16
  style,
17
17
  title: title || '',
18
+ onClick,
18
19
  });
19
20
  } }));
20
21
  };
21
- BaseOverflowTooltip.defaultProps = {
22
- className: '',
23
- title: '',
24
- maxline: 1,
25
- };
22
+ BaseOverflowTooltip.displayName = 'BaseOverflowTooltip';
26
23
  export default memo(BaseOverflowTooltip);
@@ -7,6 +7,7 @@ interface UserAvatarProps {
7
7
  };
8
8
  username?: string;
9
9
  name?: string;
10
+ nickname?: string;
10
11
  };
11
12
  }
12
13
  declare const UserAvatar: React.FC<UserAvatarProps>;
@@ -5,7 +5,7 @@ import { getBackgroundColor, getNameBadge } from '../utils';
5
5
  import { avatarItemStyle, avatarStyle, defaultAvatarStyle } from './style';
6
6
  const UserAvatar = React.memo(({ user, className }) => {
7
7
  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]);
8
- const displayName = useMemo(() => (user === null || user === void 0 ? void 0 : user.name) || (user === null || user === void 0 ? void 0 : user.username), [user]);
8
+ 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]);
9
9
  const userBadge = useMemo(() => getNameBadge(displayName), [displayName]);
10
10
  return (_jsx(ClassNames, { children: ({ cx, css }) => {
11
11
  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 }));
@@ -1,5 +1,4 @@
1
1
  export declare const getNameBadge: (name: string) => string | null;
2
- export declare const isChinese: (text: string) => boolean;
3
2
  export declare const getBackgroundColor: (s?: string) => {
4
3
  background: string;
5
4
  };
@@ -1,15 +1,11 @@
1
1
  import dayjs from '../../lib/dayjs';
2
2
  import { DATE_TIME_FORMAT, DATE_TIME_FORMAT_SEC } from '../../lib/global';
3
- const zhReg = /[\u4e00-\u9fa5]/g;
4
3
  export const getNameBadge = (name) => {
5
4
  var _a;
6
5
  if (!((_a = name === null || name === void 0 ? void 0 : name.trim) === null || _a === void 0 ? void 0 : _a.call(name)))
7
6
  return null;
8
- if (isChinese(name))
9
- return name.slice(-1);
10
7
  return name.slice(0, 1);
11
8
  };
12
- export const isChinese = (text) => zhReg.test(text);
13
9
  const randomBackgroundColor = ['#5EA1FF', '#4BCC87', '#FFD15E', '#FF945E', '#A994FF'];
14
10
  export const getBackgroundColor = (s) => {
15
11
  const code = (s === null || s === void 0 ? void 0 : s.charCodeAt(0)) || 0;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@giteeteam/apps-team-components",
3
- "version": "1.0.9",
4
- "description": "",
3
+ "version": "1.0.11",
4
+ "description": "Gitee team components",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
7
7
  "scripts": {