@lobehub/ui 1.22.0 → 1.23.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,9 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import { ActionIconProps } from "..";
3
+ import { type MenuProps } from 'antd';
3
4
  import { DivProps } from "../types";
4
5
  export interface ActionIconGroupProps extends DivProps {
5
6
  direction?: 'row' | 'column';
6
- items: ActionIconProps[];
7
+ dropdownMenu?: MenuProps['items'];
8
+ items?: ActionIconProps[];
7
9
  /**
8
10
  * @description The position of the tooltip relative to the target
9
11
  * @enum ["top","left","right","bottom","topLeft","topRight","bottomLeft","bottomRight","leftTop","leftBottom","rightTop","rightBottom"]
@@ -1,9 +1,11 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["type", "items", "placement", "spotlight", "direction"];
3
+ var _excluded = ["type", "items", "placement", "spotlight", "direction", "dropdownMenu"];
4
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
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
6
  import { ActionIcon, Spotlight } from "./..";
7
+ import { Dropdown } from 'antd';
8
+ import { MoreHorizontal } from 'lucide-react';
7
9
  import { memo } from 'react';
8
10
  import { useStyles } from "./style";
9
11
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -11,26 +13,40 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
11
13
  var ActionIconGroup = /*#__PURE__*/memo(function (_ref) {
12
14
  var _ref$type = _ref.type,
13
15
  type = _ref$type === void 0 ? 'block' : _ref$type,
14
- items = _ref.items,
16
+ _ref$items = _ref.items,
17
+ items = _ref$items === void 0 ? [] : _ref$items,
15
18
  placement = _ref.placement,
16
19
  _ref$spotlight = _ref.spotlight,
17
20
  spotlight = _ref$spotlight === void 0 ? true : _ref$spotlight,
18
21
  _ref$direction = _ref.direction,
19
22
  direction = _ref$direction === void 0 ? 'row' : _ref$direction,
23
+ _ref$dropdownMenu = _ref.dropdownMenu,
24
+ dropdownMenu = _ref$dropdownMenu === void 0 ? [] : _ref$dropdownMenu,
20
25
  props = _objectWithoutProperties(_ref, _excluded);
21
26
  var _useStyles = useStyles({
22
27
  direction: direction,
23
28
  type: type
24
29
  }),
25
30
  styles = _useStyles.styles;
31
+ var tooltipsPlacement = placement || (direction === 'column' ? 'right' : 'top');
26
32
  return /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({
27
33
  className: styles.container
28
34
  }, props), {}, {
29
35
  children: [spotlight && /*#__PURE__*/_jsx(Spotlight, {}), items.map(function (item, index) {
30
36
  return /*#__PURE__*/_jsx(ActionIcon, _objectSpread({
31
- placement: placement || (direction === 'column' ? 'right' : 'top'),
37
+ placement: tooltipsPlacement,
32
38
  size: "small"
33
39
  }, item), index);
40
+ }), dropdownMenu && /*#__PURE__*/_jsx(Dropdown, {
41
+ menu: {
42
+ items: dropdownMenu
43
+ },
44
+ trigger: ['click'],
45
+ children: /*#__PURE__*/_jsx(ActionIcon, {
46
+ icon: MoreHorizontal,
47
+ placement: tooltipsPlacement,
48
+ size: "small"
49
+ }, "more")
34
50
  })]
35
51
  }));
36
52
  });
@@ -8,7 +8,7 @@ export var useStyles = createStyles(function (_ref, _ref2) {
8
8
  cx = _ref.cx;
9
9
  var direction = _ref2.direction,
10
10
  type = _ref2.type;
11
- var typeStylish = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n border: 1px solid ", ";\n "])), type === 'block' ? token.colorFillTertiary : 'transparent', type === 'block' ? 'transparent' : token.colorBorder);
11
+ var typeStylish = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n border: 1px solid ", ";\n "])), type === 'block' ? token.colorFillTertiary : token.colorFillQuaternary, type === 'block' ? 'transparent' : token.colorBorder);
12
12
  return {
13
13
  container: cx(type !== 'pure' && typeStylish, stylish.blur, css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n\n display: flex;\n flex-direction: ", ";\n\n padding: 2px;\n\n border-radius: ", "px;\n "])), direction, token.borderRadius))
14
14
  };
@@ -17,10 +17,10 @@ var Avatar = /*#__PURE__*/memo(function (_ref) {
17
17
  shape = _ref$shape === void 0 ? 'circle' : _ref$shape,
18
18
  background = _ref.background,
19
19
  props = _objectWithoutProperties(_ref, _excluded);
20
- var isImage = avatar && ['/', 'http', 'data:'].some(function (i) {
20
+ var isImage = Boolean(avatar && ['/', 'http', 'data:'].some(function (i) {
21
21
  return avatar.startsWith(i);
22
- });
23
- var isEmoji = avatar && !isImage && /\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDE4F]/g.test(avatar);
22
+ }));
23
+ var isEmoji = Boolean(avatar && !isImage && /\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDE4F]/g.test(avatar));
24
24
  var _useStyles = useStyles({
25
25
  background: background,
26
26
  size: size,
@@ -1,6 +1,6 @@
1
1
  export declare const useStyles: (props?: {
2
2
  background?: string | undefined;
3
- isEmoji: boolean;
3
+ isEmoji?: boolean | undefined;
4
4
  size: number;
5
5
  } | undefined) => import("antd-style").ReturnStyles<{
6
6
  avatar: import("antd-style").SerializedStyles;
@@ -1,8 +1,9 @@
1
- /// <reference types="react" />
2
1
  import { type AlertProps } from 'antd';
2
+ import { ReactNode } from 'react';
3
3
  import type { DivProps } from "../types";
4
4
  import { MetaData } from "../types/meta";
5
5
  export interface ChatItemProps extends DivProps {
6
+ actions?: ReactNode;
6
7
  /**
7
8
  * @description Whether to show alert and alert config
8
9
  */
@@ -1,6 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["className", "title", "primary", "borderSpacing", "loading", "message", "placement", "type", "avatar", "alert", "showTitle", "time"];
3
+ var _excluded = ["actions", "className", "title", "primary", "borderSpacing", "loading", "message", "placement", "type", "avatar", "alert", "showTitle", "time"];
4
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
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
6
  import { Alert } from 'antd';
@@ -13,7 +13,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { jsxs as _jsxs } from "react/jsx-runtime";
14
14
  var AVATAR_SIZE = 40;
15
15
  var ChatItem = /*#__PURE__*/memo(function (_ref) {
16
- var className = _ref.className,
16
+ var actions = _ref.actions,
17
+ className = _ref.className,
17
18
  title = _ref.title,
18
19
  primary = _ref.primary,
19
20
  _ref$borderSpacing = _ref.borderSpacing,
@@ -35,7 +36,8 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
35
36
  title: title,
36
37
  primary: primary,
37
38
  avatarSize: AVATAR_SIZE,
38
- showTitle: showTitle
39
+ showTitle: showTitle,
40
+ borderSpacing: borderSpacing
39
41
  }),
40
42
  cx = _useStyles.cx,
41
43
  styles = _useStyles.styles;
@@ -65,7 +67,7 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
65
67
  children: [/*#__PURE__*/_jsxs("div", {
66
68
  className: cx(styles.name, 'chat-item-name'),
67
69
  children: [showTitle ? avatar.title || 'untitled' : null, time && /*#__PURE__*/_jsx("span", {
68
- className: cx(type === 'pure' && !showTitle && styles.time, 'chat-item-time'),
70
+ className: "chat-item-time",
69
71
  children: formatTime(time)
70
72
  })]
71
73
  }), alert ? /*#__PURE__*/_jsx(Alert, _objectSpread({
@@ -75,6 +77,9 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
75
77
  children: /*#__PURE__*/_jsx(Markdown, {
76
78
  children: String(message || '...')
77
79
  })
80
+ }), /*#__PURE__*/_jsx("div", {
81
+ className: cx(styles.actions, 'chat-item-actions'),
82
+ children: actions
78
83
  })]
79
84
  }), borderSpacing && /*#__PURE__*/_jsx("div", {
80
85
  style: {
@@ -1,5 +1,6 @@
1
1
  export declare const useStyles: (props?: {
2
2
  avatarSize: number;
3
+ borderSpacing: boolean;
3
4
  placement?: "left" | "right" | undefined;
4
5
  primary?: boolean | undefined;
5
6
  showTitle?: boolean | undefined;
@@ -11,6 +12,6 @@ export declare const useStyles: (props?: {
11
12
  avatarContainer: import("antd-style").SerializedStyles;
12
13
  messageContainer: import("antd-style").SerializedStyles;
13
14
  name: import("antd-style").SerializedStyles;
14
- time: string;
15
15
  message: string;
16
+ actions: string;
16
17
  }>;
@@ -1,28 +1,28 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
2
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12;
3
3
  import { createStyles } from 'antd-style';
4
4
  export var useStyles = createStyles(function (_ref, _ref2) {
5
5
  var cx = _ref.cx,
6
6
  css = _ref.css,
7
- token = _ref.token,
8
- stylish = _ref.stylish;
7
+ token = _ref.token;
9
8
  var placement = _ref2.placement,
10
9
  type = _ref2.type,
11
10
  title = _ref2.title,
12
11
  primary = _ref2.primary,
13
12
  avatarSize = _ref2.avatarSize,
14
- showTitle = _ref2.showTitle;
15
- var blockStylish = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 8px 12px;\n background-color: ", ";\n border-radius: ", "px;\n transition: background-color 100ms ", ";\n\n &:active {\n background-color: ", ";\n }\n "])), primary ? token.colorFillSecondary : token.colorFillTertiary, token.borderRadiusLG, token.motionEaseOut, primary ? token.colorFill : token.colorFillSecondary);
13
+ showTitle = _ref2.showTitle,
14
+ borderSpacing = _ref2.borderSpacing;
15
+ var blockStylish = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 8px 12px;\n background-color: ", ";\n border-radius: ", "px;\n transition: background-color 100ms ", ";\n "])), primary ? token.colorFillSecondary : token.colorFillTertiary, token.borderRadiusLG, token.motionEaseOut);
16
16
  var pureStylish = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding-top: ", ";\n "])), title ? 0 : '6px');
17
- var pureContainerStylish = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n border-radius: ", "px;\n transition: background-color 100ms ", ";\n\n &:hover {\n background-color: ", ";\n }\n\n &:active {\n background-color: ", ";\n }\n "])), token.borderRadiusLG, token.motionEaseOut, token.colorFillTertiary, token.colorFillSecondary);
17
+ var pureContainerStylish = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n transition: background-color 100ms ", ";\n "])), token.motionEaseOut);
18
18
  var typeStylish = type === 'block' ? blockStylish : pureStylish;
19
19
  return {
20
- container: cx(type === 'pure' && pureContainerStylish, css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: relative;\n\n display: flex;\n flex-direction: ", ";\n gap: 12px;\n align-items: flex-start;\n justify-content: revert;\n\n width: 100%;\n padding: 12px;\n\n .chat-item-time {\n display: none;\n }\n\n &:hover {\n .chat-item-time {\n display: inline-block;\n }\n }\n "])), placement === 'left' ? 'row' : 'row-reverse')),
20
+ container: cx(type === 'pure' && pureContainerStylish, css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: relative;\n\n display: flex;\n flex-direction: ", ";\n gap: 12px;\n align-items: flex-start;\n justify-content: revert;\n\n width: 100%;\n padding: 12px;\n\n .chat-item-time,\n .chat-item-actions {\n display: none;\n }\n\n &:hover {\n .chat-item-time {\n display: inline-block;\n }\n\n .chat-item-actions {\n display: flex;\n }\n }\n "])), placement === 'left' ? 'row' : 'row-reverse')),
21
21
  loading: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n position: absolute;\n right: ", ";\n bottom: 0;\n left: ", ";\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n width: 16px;\n height: 16px;\n\n color: ", ";\n\n background: ", ";\n border-radius: 50%;\n "])), placement === 'left' ? '-4px' : 'unset', placement === 'right' ? '-4px' : 'unset', token.colorBgLayout, token.colorPrimary),
22
22
  avatarContainer: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n position: relative;\n flex: none;\n width: ", "px;\n height: ", "px;\n "])), avatarSize, avatarSize),
23
23
  messageContainer: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n position: relative;\n\n .ant-alert-with-description {\n padding-block: 12px;\n padding-inline: 12px;\n }\n "]))),
24
24
  name: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n position: ", ";\n top: ", ";\n right: ", ";\n left: ", ";\n\n display: flex;\n flex-direction: ", ";\n gap: 4px;\n\n margin-bottom: 6px;\n\n font-size: 12px;\n line-height: 1;\n color: ", ";\n text-align: ", ";\n "])), showTitle ? 'relative' : 'absolute', showTitle ? 'unset' : '-16px', placement === 'right' ? '0' : 'unset', placement === 'left' ? '0' : 'unset', placement === 'left' ? 'row' : 'row-reverse', token.colorTextDescription, placement === 'left' ? 'left' : 'right'),
25
- time: cx(stylish.blur, css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n justify-content: center;\n\n padding: 4px 6px;\n\n line-height: 1;\n\n background: ", ";\n border-radius: ", "px;\n "])), token.colorFillQuaternary, token.borderRadius)),
26
- message: cx(typeStylish, css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n position: relative;\n "]))))
25
+ message: cx(typeStylish, css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n position: relative;\n "])))),
26
+ actions: cx(css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n position: absolute;\n display: flex;\n align-items: flex-start;\n justify-content: ", ";\n "])), placement === 'left' ? 'flex-end' : 'flex-start'), type === 'block' && borderSpacing ? css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n right: ", ";\n bottom: 0;\n left: ", ";\n transform: translateX(", ");\n "])), placement === 'left' ? '-4px' : 'unset', placement === 'right' ? '-4px' : 'unset', placement === 'left' ? '100%' : '-100%') : css(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n right: ", ";\n bottom: ", ";\n left: ", ";\n "])), placement === 'left' ? '0' : 'unset', type === 'block' ? '-40px' : '-32px', placement === 'right' ? '0' : 'unset'))
27
27
  };
28
28
  });
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { type ActionIconGroupProps } from "../index";
3
+ export interface ActionsBarProps extends ActionIconGroupProps {
4
+ primary?: boolean;
5
+ }
6
+ declare const ActionsBar: import("react").NamedExoticComponent<ActionsBarProps>;
7
+ export default ActionsBar;
@@ -0,0 +1,72 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
+ var _excluded = ["primary", "items", "dropdownMenu"];
5
+ 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; }
6
+ 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; }
7
+ import { Copy, Edit, RotateCw, Trash } from 'lucide-react';
8
+ import { memo, useMemo } from 'react';
9
+ import { ActionIconGroup, Icon } from "./..";
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ var ActionsBar = /*#__PURE__*/memo(function (_ref) {
12
+ var primary = _ref.primary,
13
+ _ref$items = _ref.items,
14
+ items = _ref$items === void 0 ? [] : _ref$items,
15
+ _ref$dropdownMenu = _ref.dropdownMenu,
16
+ dropdownMenu = _ref$dropdownMenu === void 0 ? [] : _ref$dropdownMenu,
17
+ props = _objectWithoutProperties(_ref, _excluded);
18
+ var groupItems = useMemo(function () {
19
+ return [primary ? {
20
+ icon: Edit,
21
+ title: 'Edit',
22
+ onClick: function onClick() {
23
+ return console.log('click Edit');
24
+ }
25
+ } : {
26
+ icon: RotateCw,
27
+ title: 'Regenerate',
28
+ onClick: function onClick() {
29
+ return console.log('click Regenerate');
30
+ }
31
+ }].concat(_toConsumableArray(items)).filter(Boolean);
32
+ }, [primary, items]);
33
+ var groupDropdownMenu = useMemo(function () {
34
+ return dropdownMenu.concat([{
35
+ key: 'Edit',
36
+ icon: /*#__PURE__*/_jsx(Icon, {
37
+ icon: Edit,
38
+ size: "small"
39
+ }),
40
+ label: 'Edit'
41
+ }, {
42
+ key: 'Copy',
43
+ icon: /*#__PURE__*/_jsx(Icon, {
44
+ icon: Copy,
45
+ size: "small"
46
+ }),
47
+ label: 'Copy'
48
+ }, {
49
+ key: 'Regenerate',
50
+ icon: /*#__PURE__*/_jsx(Icon, {
51
+ icon: RotateCw,
52
+ size: "small"
53
+ }),
54
+ label: 'Regenerate'
55
+ }, {
56
+ type: 'divider'
57
+ }, {
58
+ key: 'Delete',
59
+ icon: /*#__PURE__*/_jsx(Icon, {
60
+ icon: Trash,
61
+ size: "small"
62
+ }),
63
+ label: 'Delete'
64
+ }]).filter(Boolean);
65
+ }, [primary, dropdownMenu]);
66
+ return /*#__PURE__*/_jsx(ActionIconGroup, _objectSpread({
67
+ dropdownMenu: groupDropdownMenu,
68
+ items: groupItems,
69
+ type: "ghost"
70
+ }, props));
71
+ });
72
+ export default ActionsBar;
@@ -5,6 +5,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
5
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
6
  import { memo } from 'react';
7
7
  import { ChatItem } from "./..";
8
+ import ActionsBar from "./ActionsBar";
8
9
  import { useStyles } from "./style";
9
10
  import { jsx as _jsx } from "react/jsx-runtime";
10
11
  var ChatList = /*#__PURE__*/memo(function (_ref) {
@@ -22,6 +23,9 @@ var ChatList = /*#__PURE__*/memo(function (_ref) {
22
23
  }, props), {}, {
23
24
  children: data.map(function (item) {
24
25
  return /*#__PURE__*/_jsx(ChatItem, {
26
+ actions: /*#__PURE__*/_jsx(ActionsBar, {
27
+ primary: item.role === 'user'
28
+ }),
25
29
  avatar: item.meta,
26
30
  borderSpacing: type === 'chat',
27
31
  message: item.content,
@@ -21,6 +21,11 @@ export interface HighlighterProps extends DivProps {
21
21
  * @default true
22
22
  */
23
23
  showLanguage?: boolean;
24
+ /**
25
+ * @description Whether add spotlight background
26
+ * @default false
27
+ */
28
+ spotlight?: boolean;
24
29
  /**
25
30
  * @description The theme of the code block
26
31
  * @default 'light'
@@ -1,5 +1,10 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["children", "language", "className", "style", "theme", "copyable", "showLanguage", "type", "spotlight"];
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; }
1
6
  import { memo } from 'react';
2
- import CopyButton from "../CopyButton";
7
+ import { CopyButton, Spotlight } from "./..";
3
8
  import SyntaxHighlighter from "./SyntaxHighlighter";
4
9
  import { useStyles } from "./style";
5
10
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -16,16 +21,21 @@ export var Highlighter = /*#__PURE__*/memo(function (_ref) {
16
21
  _ref$showLanguage = _ref.showLanguage,
17
22
  showLanguage = _ref$showLanguage === void 0 ? true : _ref$showLanguage,
18
23
  _ref$type = _ref.type,
19
- type = _ref$type === void 0 ? 'block' : _ref$type;
24
+ type = _ref$type === void 0 ? 'block' : _ref$type,
25
+ spotlight = _ref.spotlight,
26
+ props = _objectWithoutProperties(_ref, _excluded);
20
27
  var _useStyles = useStyles(type),
21
28
  styles = _useStyles.styles,
22
29
  cx = _useStyles.cx;
23
30
  var container = cx(styles.container, className);
24
- return /*#__PURE__*/_jsxs("div", {
31
+ return /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({
25
32
  className: container,
26
33
  "data-code-type": "highlighter",
27
- style: style,
28
- children: [copyable && /*#__PURE__*/_jsx(CopyButton, {
34
+ style: style
35
+ }, props), {}, {
36
+ children: [spotlight && /*#__PURE__*/_jsx(Spotlight, {
37
+ size: 240
38
+ }), copyable && /*#__PURE__*/_jsx(CopyButton, {
29
39
  className: styles.button,
30
40
  content: children,
31
41
  placement: "left"
@@ -37,6 +47,6 @@ export var Highlighter = /*#__PURE__*/memo(function (_ref) {
37
47
  theme: theme,
38
48
  children: children.trim()
39
49
  })]
40
- });
50
+ }));
41
51
  });
42
52
  export default Highlighter;
@@ -9,10 +9,10 @@ export var useStyles = createStyles(function (_ref, type) {
9
9
  var prefix = "".concat(prefixCls, "-highlighter");
10
10
  var buttonHoverCls = "".concat(prefix, "-hover-btn");
11
11
  var langHoverCls = "".concat(prefix, "-hover-lang");
12
- var typeStylish = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n border: 1px solid ", ";\n\n &:hover {\n background-color: ", ";\n }\n "])), type === 'block' ? token.colorFillTertiary : 'transparent', type === 'block' ? 'transparent' : token.colorBorder, type === 'pure' ? 'transparent' : token.colorFillTertiary);
12
+ var typeStylish = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n border: 1px solid ", ";\n\n &:hover {\n background-color: ", ";\n }\n "])), type === 'block' ? token.colorFillTertiary : 'transparent', type === 'block' ? 'transparent' : token.colorBorder, type === 'block' ? token.colorFillTertiary : token.colorFillQuaternary);
13
13
  return {
14
- container: cx(prefix, typeStylish, css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n overflow: auto;\n border-radius: ", "px;\n transition: background-color 100ms ", ";\n\n &:hover {\n .", " {\n opacity: 1;\n }\n\n .", " {\n opacity: 1;\n }\n }\n\n .prism-code {\n background: none !important;\n }\n\n pre {\n margin: 0 !important;\n padding: ", " !important;\n background: none !important;\n }\n\n code {\n background: transparent !important;\n }\n "])), token.borderRadius, token.motionEaseOut, buttonHoverCls, langHoverCls, type === 'pure' ? 0 : "16px 24px")),
15
- button: cx(buttonHoverCls, css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 51;\n top: 8px;\n right: 8px;\n\n opacity: 0;\n "])))),
14
+ container: cx(prefix, type !== 'pure' && typeStylish, css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n overflow: auto;\n border-radius: ", "px;\n transition: background-color 100ms ", ";\n\n &:hover {\n .", " {\n opacity: 1;\n }\n\n .", " {\n opacity: 1;\n }\n }\n\n .prism-code {\n background: none !important;\n }\n\n pre {\n margin: 0 !important;\n padding: ", " !important;\n background: none !important;\n }\n\n code {\n background: transparent !important;\n }\n "])), token.borderRadius, token.motionEaseOut, buttonHoverCls, langHoverCls, type === 'pure' ? 0 : "16px 24px")),
15
+ button: cx(buttonHoverCls, css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 51;\n top: ", ";\n right: ", ";\n\n opacity: 0;\n "])), type === 'pure' ? 0 : '8px', type === 'pure' ? 0 : '8px')),
16
16
  lang: cx(langHoverCls, css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 50;\n right: 8px;\n bottom: 8px;\n\n color: ", ";\n\n opacity: 0;\n\n transition: opacity 0.1s;\n "])), token.colorTextPlaceholder))
17
17
  };
18
18
  });
@@ -20,6 +20,7 @@ var Code = /*#__PURE__*/memo(function (props) {
20
20
  return /*#__PURE__*/_jsx(Highlighter, {
21
21
  className: styles,
22
22
  language: (className === null || className === void 0 ? void 0 : className.replace('language-', '')) || 'markdown',
23
+ spotlight: true,
23
24
  theme: theme.appearance,
24
25
  type: "block",
25
26
  children: children instanceof Array ? children[0] : children
@@ -11,7 +11,7 @@ export var useStyles = createStyles(function (_ref, _ref2) {
11
11
  size = _ref2.size;
12
12
  var spotlightX = ((_offset$x = offset === null || offset === void 0 ? void 0 : offset.x) !== null && _offset$x !== void 0 ? _offset$x : 0) + 'px';
13
13
  var spotlightY = ((_offset$y = offset === null || offset === void 0 ? void 0 : offset.y) !== null && _offset$y !== void 0 ? _offset$y : 0) + 'px';
14
- var spotlightOpacity = outside ? '0' : isDarkMode ? '.1' : '0.07';
14
+ var spotlightOpacity = outside ? '0' : '.1';
15
15
  var spotlightSize = size + 'px';
16
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n pointer-events: none;\n\n position: absolute;\n z-index: 1;\n inset: 0;\n\n opacity: ", ";\n background: radial-gradient(\n ", " circle at ", " ", ",\n ", ",\n transparent\n );\n border-radius: inherit;\n\n transition: all 0.2s;\n "])), spotlightOpacity, spotlightSize, spotlightX, spotlightY, token.colorText);
16
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n pointer-events: none;\n\n position: absolute;\n z-index: 1;\n inset: 0;\n\n opacity: ", ";\n background: radial-gradient(\n ", " circle at ", " ", ",\n ", ",\n ", "\n );\n border-radius: inherit;\n\n transition: all 0.2s;\n "])), spotlightOpacity, spotlightSize, spotlightX, spotlightY, isDarkMode ? token.colorText : '#fff', !isDarkMode ? token.colorTextQuaternary : 'transparent');
17
17
  });
@@ -1,7 +1,7 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
2
  var _templateObject;
3
3
  import { createGlobalStyle } from 'antd-style';
4
- var GlobalStyle = createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\n html,body {\n --font-settings: \"cv01\", \"tnum\", \"kern\";\n --font-variations: \"opsz\" auto, tabular-nums;\n\n overflow-x: hidden;\n\n margin: 0;\n padding: 0;\n\n font-family: ", ";\n font-size: ", "px;\n font-feature-settings: var(--font-settings);\n font-variation-settings: var(--font-variations);\n line-height: 1;\n color: ", ";\n text-size-adjust: none;\n text-rendering: optimizelegibility;\n vertical-align: baseline;\n\n color-scheme: dark;\n background-color: ", ";\n\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n -webkit-tap-highlight-color: transparent;\n }\n \n\n * {\n\t box-sizing: border-box;\n\t vertical-align: baseline;\n }\n\n ::-webkit-scrollbar {\n\t width: 0;\n\t height: 4px;\n\t background-color: transparent;\n\n\t &-thumb {\n\t\t background-color: transparent;\n\t\t border-radius: 4px;\n\t\t transition: background-color 500ms ", ";\n\t }\n\n\t &-corner {\n\t\t display: none;\n\t }\n }\n\n #root {\n\t min-height: 100vh;\n }\n\n p {\n text-align: justify;\n word-wrap: break-word;\n }\n \n code {\n\t font-family: ", " !important;\n\n\t * {\n\t\t font-family: inherit !important;\n\t }\n }\n\n *:hover, *:focus {\n\t ::-webkit-scrollbar {\n\t\t &-thumb {\n\t\t\t background-color: ", ";\n\t\t }\n\t }\n }\n"])), function (_ref) {
4
+ var GlobalStyle = createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\n html,body {\n --font-settings: \"cv01\", \"tnum\", \"kern\";\n --font-variations: \"opsz\" auto, tabular-nums;\n\n overflow-x: hidden;\n\n margin: 0;\n padding: 0;\n\n font-family: ", ";\n font-size: ", "px;\n font-feature-settings: var(--font-settings);\n font-variation-settings: var(--font-variations);\n line-height: 1;\n color: ", ";\n text-size-adjust: none;\n text-rendering: optimizelegibility;\n vertical-align: baseline;\n\n color-scheme: dark;\n background-color: ", ";\n\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n -webkit-tap-highlight-color: transparent;\n }\n\n\n * {\n\t box-sizing: border-box;\n\t vertical-align: baseline;\n }\n\n ::selection {\n color: #000;\n background: ", ";\n }\n\n ::-webkit-scrollbar {\n\t width: 0;\n\t height: 4px;\n\t background-color: transparent;\n\n\t &-thumb {\n\t\t background-color: transparent;\n\t\t border-radius: 4px;\n\t\t transition: background-color 500ms ", ";\n\t }\n\n\t &-corner {\n\t\t display: none;\n\t }\n }\n\n #root {\n\t min-height: 100vh;\n }\n\n p {\n text-align: justify;\n word-wrap: break-word;\n }\n\n code {\n\t font-family: ", " !important;\n\n\t * {\n\t\t font-family: inherit !important;\n\t }\n }\n\n *:hover, *:focus {\n\t ::-webkit-scrollbar {\n\t\t &-thumb {\n\t\t\t background-color: ", ";\n\t\t }\n\t }\n }\n"])), function (_ref) {
5
5
  var theme = _ref.theme;
6
6
  return theme.fontFamily;
7
7
  }, function (_ref2) {
@@ -15,12 +15,15 @@ var GlobalStyle = createGlobalStyle(_templateObject || (_templateObject = _tagge
15
15
  return theme.colorBgLayout;
16
16
  }, function (_ref5) {
17
17
  var theme = _ref5.theme;
18
- return theme.motionEaseOut;
18
+ return theme.yellow9;
19
19
  }, function (_ref6) {
20
20
  var theme = _ref6.theme;
21
- return theme.fontFamilyCode;
21
+ return theme.motionEaseOut;
22
22
  }, function (_ref7) {
23
23
  var theme = _ref7.theme;
24
+ return theme.fontFamilyCode;
25
+ }, function (_ref8) {
26
+ var theme = _ref8.theme;
24
27
  return theme.colorFill;
25
28
  });
26
29
  export default GlobalStyle;
@@ -6,6 +6,6 @@ export var generateCustomStylish = function generateCustomStylish(_ref) {
6
6
  isDarkMode = _ref.isDarkMode;
7
7
  return {
8
8
  blur: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n backdrop-filter: saturate(180%) blur(10px);\n "]))),
9
- markdown: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n color: ", ";\n\n h1,\n h2,\n h3,\n h4,\n h5 {\n font-weight: 600;\n }\n\n p {\n margin-block-start: 0;\n margin-block-end: 0;\n\n font-size: 14px;\n line-height: 1.8;\n color: ", ";\n text-align: justify;\n word-wrap: break-word;\n\n + * {\n margin-block-end: 0.5em;\n }\n }\n\n blockquote {\n margin: 16px 0;\n padding: 0 12px;\n\n p {\n font-style: italic;\n color: ", ";\n }\n }\n\n p:not(:last-child) {\n margin-bottom: 1em;\n }\n\n a {\n color: ", ";\n\n &:hover {\n color: ", ";\n }\n\n &:active {\n color: ", ";\n }\n }\n\n img {\n max-width: 100%;\n }\n\n pre {\n border-radius: ", "px;\n }\n\n > :not([data-code-type='highlighter']) code {\n padding: 2px 6px;\n\n font-size: ", "px;\n color: ", ";\n\n background: ", ";\n border: 1px solid ", ";\n border-radius: ", "px;\n }\n\n table {\n border-spacing: 0;\n\n width: 100%;\n margin-block-start: 1em;\n margin-block-end: 1em;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 8px;\n\n border: 1px solid ", ";\n border-radius: ", "px;\n }\n\n th,\n td {\n padding-block-start: 10px;\n padding-block-end: 10px;\n padding-inline-start: 16px;\n padding-inline-end: 16px;\n }\n\n thead {\n tr {\n th {\n background: ", ";\n\n &:first-child {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n }\n\n &:last-child {\n border-top-right-radius: ", "px;\n border-bottom-right-radius: ", "px;\n }\n }\n }\n }\n\n ul li {\n line-height: 1.8;\n }\n "])), isDarkMode ? token.colorTextSecondary : token.colorText, token.colorText, token.colorTextDescription, token.colorLink, token.colorLinkHover, token.colorLinkActive, token.borderRadius, token.fontSizeSM, isDarkMode ? token.cyan9A : token.cyan10A, isDarkMode ? token.cyan1A : token.cyan3A, isDarkMode ? token.cyan1A : token.cyan4A, token.borderRadiusSM, token.colorBorderSecondary, token.borderRadius, token.colorFillTertiary, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius)
9
+ markdown: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n color: ", ";\n\n h1,\n h2,\n h3,\n h4,\n h5 {\n font-weight: 600;\n }\n\n p {\n margin-block-start: 0;\n margin-block-end: 0;\n\n font-size: 14px;\n line-height: 1.8;\n color: ", ";\n text-align: justify;\n word-wrap: break-word;\n\n + * {\n margin-block-end: 0.5em;\n }\n }\n\n blockquote {\n margin: 16px 0;\n padding: 0 12px;\n\n p {\n font-style: italic;\n color: ", ";\n }\n }\n\n p:not(:last-child) {\n margin-bottom: 1em;\n }\n\n a {\n color: ", ";\n\n &:hover {\n color: ", ";\n }\n\n &:active {\n color: ", ";\n }\n }\n\n img {\n max-width: 100%;\n }\n\n pre {\n border: none;\n border-radius: ", "px;\n }\n\n > :not([data-code-type='highlighter']) code {\n padding: 2px 6px;\n\n font-size: ", "px;\n color: ", ";\n\n background: ", ";\n border: 1px solid ", ";\n border-radius: ", "px;\n }\n\n table {\n border-spacing: 0;\n\n width: 100%;\n margin-block-start: 1em;\n margin-block-end: 1em;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 8px;\n\n border: 1px solid ", ";\n border-radius: ", "px;\n }\n\n th,\n td {\n padding-block-start: 10px;\n padding-block-end: 10px;\n padding-inline-start: 16px;\n padding-inline-end: 16px;\n }\n\n thead {\n tr {\n th {\n background: ", ";\n\n &:first-child {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n }\n\n &:last-child {\n border-top-right-radius: ", "px;\n border-bottom-right-radius: ", "px;\n }\n }\n }\n }\n\n ul li {\n line-height: 1.8;\n }\n "])), isDarkMode ? token.colorTextSecondary : token.colorText, token.colorText, token.colorTextDescription, token.colorLink, token.colorLinkHover, token.colorLinkActive, token.borderRadius, token.fontSizeSM, isDarkMode ? token.cyan9A : token.cyan10A, isDarkMode ? token.cyan1A : token.cyan3A, isDarkMode ? token.cyan1A : token.cyan4A, token.borderRadiusSM, token.colorBorderSecondary, token.borderRadius, token.colorFillTertiary, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius)
10
10
  };
11
11
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.22.0",
3
+ "version": "1.23.0",
4
4
  "description": "Lobe UI is an open-source UI component library for building chatbot web apps",
5
5
  "keywords": [
6
6
  "lobehub",