@lobehub/ui 1.123.0 → 1.124.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.
@@ -1,11 +1,11 @@
1
- /// <reference types="react" />
2
1
  import { type AvatarProps as AntAvatarProps } from 'antd';
2
+ import { type ReactNode } from 'react';
3
3
  export interface AvatarProps extends AntAvatarProps {
4
4
  animation?: boolean;
5
5
  /**
6
6
  * @description The URL or base64 data of the avatar image
7
7
  */
8
- avatar?: string;
8
+ avatar?: string | ReactNode;
9
9
  /**
10
10
  * @description The background color of the avatar
11
11
  */
@@ -4,7 +4,7 @@ var _excluded = ["className", "avatar", "title", "animation", "size", "shape", "
4
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
6
  import { Avatar as AntAvatar } from 'antd';
7
- import { memo, useMemo } from 'react';
7
+ import { isValidElement, memo, useMemo } from 'react';
8
8
  import FluentEmoji from "../FluentEmoji";
9
9
  import { getEmoji } from "../utils/getEmojiByCharacter";
10
10
  import { useStyles } from "./style";
@@ -22,11 +22,12 @@ var Avatar = /*#__PURE__*/memo(function (_ref) {
22
22
  background = _ref$background === void 0 ? 'rgba(0,0,0,0)' : _ref$background,
23
23
  style = _ref.style,
24
24
  rest = _objectWithoutProperties(_ref, _excluded);
25
- var isImage = Boolean(avatar && ['/', 'http', 'data:'].some(function (index) {
26
- return avatar.startsWith(index);
27
- }));
25
+ var isStringAvatar = typeof avatar === 'string';
26
+ var isDefaultAntAvatar = Boolean(avatar && (['/', 'http', 'data:'].some(function (index) {
27
+ return isStringAvatar && avatar.startsWith(index);
28
+ }) || /*#__PURE__*/isValidElement(avatar)));
28
29
  var emoji = useMemo(function () {
29
- return avatar && !isImage && getEmoji(avatar);
30
+ return avatar && !isDefaultAntAvatar && isStringAvatar && getEmoji(avatar);
30
31
  }, [avatar]);
31
32
  var _useStyles = useStyles({
32
33
  background: background,
@@ -35,7 +36,7 @@ var Avatar = /*#__PURE__*/memo(function (_ref) {
35
36
  }),
36
37
  styles = _useStyles.styles,
37
38
  cx = _useStyles.cx;
38
- var text = String(isImage ? title : avatar);
39
+ var text = String(isDefaultAntAvatar ? title : avatar);
39
40
  var avatarProps = _objectSpread({
40
41
  className: cx(styles.avatar, className),
41
42
  shape: shape,
@@ -44,7 +45,7 @@ var Avatar = /*#__PURE__*/memo(function (_ref) {
44
45
  cursor: 'default'
45
46
  }, style)
46
47
  }, rest);
47
- return isImage ? /*#__PURE__*/_jsx(AntAvatar, _objectSpread({
48
+ return isDefaultAntAvatar ? /*#__PURE__*/_jsx(AntAvatar, _objectSpread({
48
49
  src: avatar
49
50
  }, avatarProps)) : /*#__PURE__*/_jsx(AntAvatar, _objectSpread(_objectSpread({}, avatarProps), {}, {
50
51
  children: emoji ? /*#__PURE__*/_jsx(FluentEmoji, {
package/es/Form/style.js CHANGED
@@ -7,6 +7,6 @@ export var useStyles = createStyles(function (_ref) {
7
7
  prefixCls = _ref.prefixCls,
8
8
  responsive = _ref.responsive;
9
9
  return {
10
- form: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n\n display: flex;\n flex-direction: column;\n gap: 16px;\n\n width: 100%;\n\n ", " {\n gap: 0;\n }\n\n .", "-form-item {\n margin: 0 !important;\n }\n\n .", "-form-item .", "-form-item-label > label {\n height: unset;\n }\n\n .", "-row {\n position: relative;\n flex-wrap: nowrap;\n }\n\n .", "-form-item-label {\n position: relative;\n flex: 1;\n max-width: 100%;\n }\n\n .", "-form-item-row {\n align-items: center;\n }\n\n .", "-form-item-control {\n position: relative;\n\n display: flex;\n flex: 0;\n align-items: center;\n\n min-width: unset !important;\n }\n\n .", "-collapse-item {\n overflow: hidden !important;\n border-radius: ", "px !important;\n }\n "])), responsive.mobile, prefixCls, prefixCls, prefixCls, prefixCls, prefixCls, prefixCls, prefixCls, prefixCls, token.borderRadius)
10
+ form: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n\n display: flex;\n flex-direction: column;\n gap: 16px;\n\n width: 100%;\n\n ", " {\n gap: 0;\n }\n\n .", "-form-item {\n margin: 0 !important;\n }\n\n .", "-form-item .", "-form-item-label > label {\n height: unset;\n }\n\n .", "-row {\n position: relative;\n flex-wrap: nowrap;\n }\n\n .", "-form-item-label {\n position: relative;\n flex: 1;\n max-width: 100%;\n }\n\n .", "-form-item-row {\n align-items: center;\n ", " {\n align-items: stretch;\n }\n }\n\n .", "-form-item-control {\n position: relative;\n flex: 0;\n min-width: unset !important;\n }\n\n .", "-collapse-item {\n overflow: hidden !important;\n border-radius: ", "px !important;\n }\n "])), responsive.mobile, prefixCls, prefixCls, prefixCls, prefixCls, prefixCls, prefixCls, responsive.mobile, prefixCls, prefixCls, token.borderRadius)
11
11
  };
12
12
  });
@@ -46,9 +46,9 @@ export var usePreview = function usePreview() {
46
46
  },
47
47
  maxScale: maxScale,
48
48
  minScale: minScale,
49
- onVisibleChange: function onVisibleChange(e) {
50
- setVisible(e);
51
- _onVisibleChange === null || _onVisibleChange === void 0 || _onVisibleChange(e);
49
+ onVisibleChange: function onVisibleChange(visible, prevVisible, current) {
50
+ setVisible(visible);
51
+ _onVisibleChange === null || _onVisibleChange === void 0 || _onVisibleChange(visible, prevVisible, current);
52
52
  },
53
53
  styles: _objectSpread({
54
54
  mask: {
@@ -18,7 +18,8 @@ var SliderWithInput = /*#__PURE__*/memo(function (_ref) {
18
18
  defaultValue = _ref.defaultValue,
19
19
  size = _ref.size,
20
20
  controls = _ref.controls,
21
- gap = _ref.gap,
21
+ _ref$gap = _ref.gap,
22
+ gap = _ref$gap === void 0 ? 16 : _ref$gap,
22
23
  style = _ref.style,
23
24
  className = _ref.className,
24
25
  disabled = _ref.disabled,
@@ -31,7 +32,7 @@ var SliderWithInput = /*#__PURE__*/memo(function (_ref) {
31
32
  align: 'center',
32
33
  className: className,
33
34
  direction: 'horizontal',
34
- gap: gap !== null && gap !== void 0 ? gap : 8,
35
+ gap: gap,
35
36
  style: style,
36
37
  children: [/*#__PURE__*/_jsx(Slider, _objectSpread({
37
38
  defaultValue: defaultValue,
@@ -1,9 +1,10 @@
1
+ import { type ReactNode } from 'react';
1
2
  export interface MetaData {
2
3
  /**
3
4
  * 角色头像
4
5
  * @description 可选参数,如果不传则使用默认头像
5
6
  */
6
- avatar?: string;
7
+ avatar?: string | ReactNode;
7
8
  /**
8
9
  * 背景色
9
10
  * @description 可选参数,如果不传则使用默认背景色
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.123.0",
3
+ "version": "1.124.0",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",