x-star-design 0.0.12 → 0.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/dist/index.d.ts CHANGED
@@ -9,3 +9,4 @@ export { default as RainbowCat } from './rainbow-cat';
9
9
  export { default as StatusTag } from './status-tag';
10
10
  export type { StatusTagProps, StatusTagShape, StatusTagStyle, StatusTagType, } from './status-tag/define';
11
11
  export { default as TitleWithIcon } from './title-with-icon';
12
+ export { default as UserAvatar } from './user-avatar';
package/dist/index.js CHANGED
@@ -6,4 +6,5 @@ export { default as ErrorBoundary } from "./error-boundary";
6
6
  export { default as LoadingMask } from "./loading-mask";
7
7
  export { default as RainbowCat } from "./rainbow-cat";
8
8
  export { default as StatusTag } from "./status-tag";
9
- export { default as TitleWithIcon } from "./title-with-icon";
9
+ export { default as TitleWithIcon } from "./title-with-icon";
10
+ export { default as UserAvatar } from "./user-avatar";
@@ -1,3 +1,4 @@
1
1
  declare module '*.svg' {
2
2
  export default string;
3
3
  }
4
+ declare module 'randomcolor';
@@ -0,0 +1,10 @@
1
+ import { AvatarProps } from 'antd/lib/avatar';
2
+ import React from 'react';
3
+ type UserAvatarProps = AvatarProps & {
4
+ user: {
5
+ realName?: string;
6
+ userName?: string;
7
+ } | null | undefined;
8
+ };
9
+ declare const UserAvatar: React.FC<UserAvatarProps>;
10
+ export default UserAvatar;
@@ -0,0 +1,35 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ var _excluded = ["user", "style"];
3
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
9
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
10
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
11
+ import { Avatar, Tooltip } from 'antd';
12
+ import randomColor from 'randomcolor';
13
+ import React, { useMemo } from 'react';
14
+ var UserAvatar = function UserAvatar(_ref) {
15
+ var _ref2, _ref2$filter;
16
+ var user = _ref.user,
17
+ style = _ref.style,
18
+ props = _objectWithoutProperties(_ref, _excluded);
19
+ var name = ((_ref2 = [user === null || user === void 0 ? void 0 : user.realName, user === null || user === void 0 ? void 0 : user.userName]) === null || _ref2 === void 0 ? void 0 : (_ref2$filter = _ref2.filter(Boolean)) === null || _ref2$filter === void 0 ? void 0 : _ref2$filter.join(' | ')) || 'Unknown';
20
+ var background = useMemo(function () {
21
+ return randomColor({
22
+ luminosity: 'bright',
23
+ seed: name,
24
+ format: 'rgb'
25
+ });
26
+ }, [name]);
27
+ return /*#__PURE__*/React.createElement(Tooltip, {
28
+ title: name
29
+ }, /*#__PURE__*/React.createElement(Avatar, _extends({
30
+ style: _objectSpread({
31
+ background: background
32
+ }, style)
33
+ }, props), name[0].toUpperCase()));
34
+ };
35
+ export default UserAvatar;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-star-design",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "A react component library developed by turingstar",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -57,14 +57,17 @@
57
57
  "@uiw/react-codemirror": "^4.21.9",
58
58
  "ahooks": "^3.7.8",
59
59
  "classnames": "^2.3.2",
60
+ "randomcolor": "^0.6.2",
60
61
  "x-star-utils": "^0.0.4"
61
62
  },
62
63
  "devDependencies": {
64
+ "@ant-design/icons": "4.7.0",
63
65
  "@commitlint/cli": "^17.1.2",
64
66
  "@commitlint/config-conventional": "^17.1.0",
65
67
  "@types/react": "^18.0.0",
66
68
  "@types/react-dom": "^18.0.0",
67
69
  "@umijs/lint": "^4.0.0",
70
+ "antd": "5.2.2",
68
71
  "dumi": "^2.2.0",
69
72
  "eslint": "^8.23.0",
70
73
  "father": "^4.1.0",
@@ -79,6 +82,8 @@
79
82
  "stylelint-config-standard-scss": "^6.1.0"
80
83
  },
81
84
  "peerDependencies": {
85
+ "@ant-design/icons": ">=4.7.0",
86
+ "antd": ">=4.23",
82
87
  "react": ">=16.9.0",
83
88
  "react-dom": ">=16.9.0"
84
89
  },