@lobehub/ui 1.106.1 → 1.107.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.
@@ -7,6 +7,11 @@ export interface ActionIconGroupItems {
7
7
  key: string;
8
8
  label: string;
9
9
  }
10
+ export interface ActionEvent {
11
+ item: ActionIconGroupItems;
12
+ key: string;
13
+ keyPath: string[];
14
+ }
10
15
  export interface ActionIconGroupProps extends DivProps {
11
16
  /**
12
17
  * @description The direction of the icons
@@ -24,7 +29,7 @@ export interface ActionIconGroupProps extends DivProps {
24
29
  * @default []
25
30
  */
26
31
  items?: ActionIconGroupItems[];
27
- onActionClick?: (key: string) => void;
32
+ onActionClick?: (action: ActionEvent) => void;
28
33
  /**
29
34
  * @description The position of the tooltip relative to the target
30
35
  * @enum ["top","left","right","bottom","topLeft","topRight","bottomLeft","bottomRight","leftTop","leftBottom","rightTop","rightBottom"]
@@ -37,7 +37,11 @@ var ActionIconGroup = /*#__PURE__*/memo(function (_ref) {
37
37
  return /*#__PURE__*/_jsx(ActionIcon, {
38
38
  icon: item.icon,
39
39
  onClick: onActionClick ? function () {
40
- return onActionClick === null || onActionClick === void 0 ? void 0 : onActionClick(item.key);
40
+ return onActionClick === null || onActionClick === void 0 ? void 0 : onActionClick({
41
+ item: item,
42
+ key: item.key,
43
+ keyPath: [item.key]
44
+ });
41
45
  } : undefined,
42
46
  placement: tooltipsPlacement,
43
47
  size: "small",
@@ -52,8 +56,12 @@ var ActionIconGroup = /*#__PURE__*/memo(function (_ref) {
52
56
  icon: item.icon,
53
57
  size: "small"
54
58
  }),
55
- onClick: onActionClick ? function () {
56
- return onActionClick(item.key);
59
+ onClick: onActionClick ? function (info) {
60
+ return onActionClick({
61
+ item: item,
62
+ key: info.key,
63
+ keyPath: info.keyPath
64
+ });
57
65
  } : undefined
58
66
  });
59
67
  })
@@ -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", "avatar", "title", "animation", "size", "shape", "background"];
3
+ var _excluded = ["className", "avatar", "title", "animation", "size", "shape", "background", "onClick", "style"];
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 { Avatar as AntAvatar } from 'antd';
@@ -20,6 +20,8 @@ var Avatar = /*#__PURE__*/memo(function (_ref) {
20
20
  shape = _ref$shape === void 0 ? 'circle' : _ref$shape,
21
21
  _ref$background = _ref.background,
22
22
  background = _ref$background === void 0 ? 'rgba(0,0,0,0)' : _ref$background,
23
+ onClick = _ref.onClick,
24
+ style = _ref.style,
23
25
  props = _objectWithoutProperties(_ref, _excluded);
24
26
  var isImage = Boolean(avatar && ['/', 'http', 'data:'].some(function (index) {
25
27
  return avatar.startsWith(index);
@@ -36,17 +38,18 @@ var Avatar = /*#__PURE__*/memo(function (_ref) {
36
38
  styles = _useStyles.styles,
37
39
  cx = _useStyles.cx;
38
40
  var text = String(isImage ? title : avatar);
39
- return isImage ? /*#__PURE__*/_jsx(AntAvatar, _objectSpread({
41
+ var avatarProps = {
40
42
  className: cx(styles.avatar, className),
41
43
  shape: shape,
42
44
  size: size,
45
+ style: onClick ? style : _objectSpread({
46
+ cursor: 'default'
47
+ }, style)
48
+ };
49
+ return isImage ? /*#__PURE__*/_jsx(AntAvatar, _objectSpread(_objectSpread({
43
50
  src: isBase64 ? avatar : undefined,
44
51
  srcSet: isBase64 ? undefined : avatar
45
- }, props)) : /*#__PURE__*/_jsx(AntAvatar, _objectSpread(_objectSpread({
46
- className: cx(styles.avatar, className),
47
- shape: shape,
48
- size: size
49
- }, props), {}, {
52
+ }, avatarProps), props)) : /*#__PURE__*/_jsx(AntAvatar, _objectSpread(_objectSpread(_objectSpread({}, avatarProps), props), {}, {
50
53
  children: emoji ? /*#__PURE__*/_jsx(FluentEmoji, {
51
54
  emoji: emoji,
52
55
  size: size * 0.8,
@@ -1,10 +1,11 @@
1
1
  import { FC, ReactNode } from 'react';
2
+ import { ActionEvent } from "../ActionIconGroup";
2
3
  import { type ChatItemProps } from "../ChatItem";
3
4
  import { ChatMessage } from "../types/chatMessage";
4
5
  import { LLMRoleType } from "../types/llm";
5
6
  import { type ActionsBarProps } from './ActionsBar';
6
7
  export type OnMessageChange = (id: string, content: string) => void;
7
- export type OnActionClick = (props: ChatMessage) => void;
8
+ export type OnActionClick = (action: ActionEvent, message: ChatMessage) => void;
8
9
  export type RenderRole = LLMRoleType | 'default' | string;
9
10
  export type RenderItem = FC<{
10
11
  key: string;
@@ -21,9 +22,7 @@ export interface ListItemProps {
21
22
  /**
22
23
  * @description 点击操作按钮的回调函数
23
24
  */
24
- onActionsClick?: {
25
- [actionKey: string]: OnActionClick;
26
- };
25
+ onActionsClick?: OnActionClick;
27
26
  /**
28
27
  * @description 消息变化的回调函数
29
28
  */
@@ -5,7 +5,7 @@ var _excluded = ["renderMessagesExtra", "showTitle", "onActionsClick", "onMessag
5
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
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
7
  import { App } from 'antd';
8
- import _copy from 'copy-to-clipboard';
8
+ import copy from 'copy-to-clipboard';
9
9
  import { memo, useCallback, useMemo, useState } from 'react';
10
10
  import ChatItem from "../ChatItem";
11
11
  import ActionsBar from "./ActionsBar";
@@ -77,20 +77,24 @@ var Item = /*#__PURE__*/memo(function (props) {
77
77
  if (renderActions !== null && renderActions !== void 0 && renderActions[item.role]) RenderFunction = renderActions[item.role];
78
78
  if (renderActions !== null && renderActions !== void 0 && renderActions['default']) RenderFunction = renderActions['default'];
79
79
  if (!RenderFunction) RenderFunction = ActionsBar;
80
- var handleActionClick = _objectSpread({
81
- copy: function copy(_ref5) {
82
- var content = _ref5.content;
83
- _copy(content);
84
- message.success((text === null || text === void 0 ? void 0 : text.copySuccess) || 'Copy Success');
85
- },
86
- edit: function edit() {
87
- return setEditing(true);
80
+ var handleActionClick = function handleActionClick(action, data) {
81
+ switch (action.key) {
82
+ case 'copy':
83
+ {
84
+ copy(data.content);
85
+ message.success((text === null || text === void 0 ? void 0 : text.copySuccess) || 'Copy Success');
86
+ break;
87
+ }
88
+ case 'edit':
89
+ {
90
+ setEditing(true);
91
+ }
88
92
  }
89
- }, onActionsClick);
93
+ onActionsClick === null || onActionsClick === void 0 ? void 0 : onActionsClick(action, data);
94
+ };
90
95
  return /*#__PURE__*/_jsx(RenderFunction, _objectSpread(_objectSpread({}, data), {}, {
91
96
  onActionClick: function onActionClick(actionKey) {
92
- var _handleActionClick$ac;
93
- return handleActionClick === null || handleActionClick === void 0 ? void 0 : (_handleActionClick$ac = handleActionClick[actionKey]) === null || _handleActionClick$ac === void 0 ? void 0 : _handleActionClick$ac.call(handleActionClick, data);
97
+ return handleActionClick === null || handleActionClick === void 0 ? void 0 : handleActionClick(actionKey, data);
94
98
  },
95
99
  text: text
96
100
  }));
@@ -25,6 +25,10 @@ export interface EditableMessageProps {
25
25
  fullFeaturedCodeBlock?: boolean;
26
26
  height?: MessageInputProps['height'];
27
27
  inputType?: MessageInputProps['type'];
28
+ model?: {
29
+ extra?: MessageModalProps['extra'];
30
+ footer?: MessageModalProps['footer'];
31
+ };
28
32
  /**
29
33
  * @title Callback function when the value changes
30
34
  * @param value - The new value
@@ -28,7 +28,8 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
28
28
  inputType = _ref.inputType,
29
29
  editButtonSize = _ref.editButtonSize,
30
30
  text = _ref.text,
31
- fullFeaturedCodeBlock = _ref.fullFeaturedCodeBlock;
31
+ fullFeaturedCodeBlock = _ref.fullFeaturedCodeBlock,
32
+ model = _ref.model;
32
33
  var _useControlledState = useControlledState(false, {
33
34
  onChange: onEditingChange,
34
35
  value: editing
@@ -78,6 +79,8 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
78
79
  children: value || placeholder
79
80
  }), /*#__PURE__*/_jsx(MessageModal, {
80
81
  editing: isEdit,
82
+ extra: model === null || model === void 0 ? void 0 : model.extra,
83
+ footer: model === null || model === void 0 ? void 0 : model.footer,
81
84
  height: height,
82
85
  onChange: function onChange(text) {
83
86
  return _onChange === null || _onChange === void 0 ? void 0 : _onChange(text);
@@ -1,11 +1,13 @@
1
- /// <reference types="react" />
1
+ import { ReactNode } from 'react';
2
2
  import { type MessageInputProps } from "../MessageInput";
3
- export interface MessageModalProps {
3
+ import { type ModalProps } from "../Modal";
4
+ export interface MessageModalProps extends Pick<ModalProps, 'open' | 'footer'> {
4
5
  /**
5
6
  * @description Whether the message is being edited or not
6
7
  * @default false
7
8
  */
8
9
  editing?: boolean;
10
+ extra?: ReactNode;
9
11
  height?: MessageInputProps['height'];
10
12
  /**
11
13
  * @description Callback fired when message content is changed
@@ -23,7 +25,6 @@ export interface MessageModalProps {
23
25
  * @description Whether the modal is open or not
24
26
  * @default false
25
27
  */
26
- open?: boolean;
27
28
  placeholder?: string;
28
29
  text?: {
29
30
  cancel?: string;
@@ -9,6 +9,8 @@ import Markdown from "../Markdown";
9
9
  import MessageInput from "../MessageInput";
10
10
  import Modal from "../Modal";
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
+ import { Fragment as _Fragment } from "react/jsx-runtime";
13
+ import { jsxs as _jsxs } from "react/jsx-runtime";
12
14
  var MessageModal = /*#__PURE__*/memo(function (_ref) {
13
15
  var editing = _ref.editing,
14
16
  open = _ref.open,
@@ -19,7 +21,9 @@ var MessageModal = /*#__PURE__*/memo(function (_ref) {
19
21
  placeholder = _ref.placeholder,
20
22
  value = _ref.value,
21
23
  onChange = _ref.onChange,
22
- text = _ref.text;
24
+ text = _ref.text,
25
+ footer = _ref.footer,
26
+ extra = _ref.extra;
23
27
  var _useResponsive = useResponsive(),
24
28
  mobile = _useResponsive.mobile;
25
29
  var _useControlledState = useControlledState(false, {
@@ -44,7 +48,7 @@ var MessageModal = /*#__PURE__*/memo(function (_ref) {
44
48
  };
45
49
  return /*#__PURE__*/_jsx(Modal, {
46
50
  cancelText: (text === null || text === void 0 ? void 0 : text.cancel) || 'Cancel',
47
- footer: isEdit ? null : undefined,
51
+ footer: isEdit ? null : footer,
48
52
  okText: (text === null || text === void 0 ? void 0 : text.edit) || 'Edit',
49
53
  onCancel: function onCancel() {
50
54
  return setExpand(false);
@@ -75,11 +79,13 @@ var MessageModal = /*#__PURE__*/memo(function (_ref) {
75
79
  confirm: text === null || text === void 0 ? void 0 : text.confirm
76
80
  },
77
81
  type: 'block'
78
- }) : /*#__PURE__*/_jsx(Markdown, {
79
- style: value ? markdownStyle : _objectSpread(_objectSpread({}, markdownStyle), {}, {
80
- opacity: 0.5
81
- }),
82
- children: String(value || placeholder)
82
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
83
+ children: [extra, /*#__PURE__*/_jsx(Markdown, {
84
+ style: value ? markdownStyle : _objectSpread(_objectSpread({}, markdownStyle), {}, {
85
+ opacity: 0.5
86
+ }),
87
+ children: String(value || placeholder)
88
+ })]
83
89
  })
84
90
  });
85
91
  });
@@ -4,9 +4,8 @@ var _excluded = ["children", "customStylish", "customToken", "enableWebfonts", "
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 { App } from 'antd';
7
- import { ThemeProvider as AntdThemeProvider, StyleProvider, setupStyled } from 'antd-style';
8
- import { memo, useCallback, useEffect } from 'react';
9
- import { ThemeContext } from 'styled-components';
7
+ import { ThemeProvider as AntdThemeProvider, StyleProvider } from 'antd-style';
8
+ import { memo, useCallback } from 'react';
10
9
  import { useCdnFn } from "../ConfigProvider";
11
10
  import FontLoader from "../FontLoader";
12
11
  import { lobeCustomStylish, lobeCustomToken } from "../styles";
@@ -43,11 +42,6 @@ var ThemeProvider = /*#__PURE__*/memo(function (_ref) {
43
42
  pkg: 'katex',
44
43
  version: '0.16.8'
45
44
  })];
46
- useEffect(function () {
47
- setupStyled({
48
- ThemeContext: ThemeContext
49
- });
50
- }, []);
51
45
  var stylish = useCallback(function (theme) {
52
46
  return _objectSpread(_objectSpread({}, lobeCustomStylish(theme)), customStylish === null || customStylish === void 0 ? void 0 : customStylish(theme));
53
47
  }, [customStylish]);
@@ -1,5 +1,4 @@
1
1
  import 'antd-style';
2
- import { AntdToken } from 'antd-style/lib/types/theme';
3
2
 
4
3
  import { LobeCustomStylish } from './customStylish';
5
4
  import { LobeCustomToken } from './customToken';
@@ -10,7 +9,3 @@ declare module 'antd-style' {
10
9
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
11
10
  export interface CustomStylish extends LobeCustomStylish {}
12
11
  }
13
-
14
- declare module 'styled-components' {
15
- export interface DefaultTheme extends AntdToken, LobeCustomToken {}
16
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.106.1",
3
+ "version": "1.107.0",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",
@@ -105,7 +105,6 @@
105
105
  "remark-gfm": "^3",
106
106
  "remark-math": "^5",
107
107
  "shikiji": "^0",
108
- "styled-components": "^6",
109
108
  "swr": "^2",
110
109
  "three": "^0.150",
111
110
  "ts-md5": "^1",
@@ -143,6 +142,7 @@
143
142
  "remark": "^14",
144
143
  "remark-cli": "^11",
145
144
  "semantic-release": "^21",
145
+ "styled-components": "^6",
146
146
  "stylelint": "^15",
147
147
  "typescript": "^5",
148
148
  "vitest": "latest"