@lobehub/ui 1.20.0 → 1.21.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.
@@ -4,35 +4,13 @@ var _excluded = ["className", "active", "icon", "size", "style", "glass", "title
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 { Loader2 } from 'lucide-react';
7
- import { memo } from 'react';
7
+ import { memo, useMemo } from 'react';
8
8
  import { Icon, Spotlight, Tooltip } from "./..";
9
9
  import { useStyles } from "./style";
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  import { Fragment as _Fragment } from "react/jsx-runtime";
12
12
  import { jsxs as _jsxs } from "react/jsx-runtime";
13
- var ActionIcon = /*#__PURE__*/memo(function (_ref) {
14
- var className = _ref.className,
15
- active = _ref.active,
16
- icon = _ref.icon,
17
- _ref$size = _ref.size,
18
- size = _ref$size === void 0 ? 'normal' : _ref$size,
19
- style = _ref.style,
20
- glass = _ref.glass,
21
- title = _ref.title,
22
- placement = _ref.placement,
23
- _ref$arrow = _ref.arrow,
24
- arrow = _ref$arrow === void 0 ? false : _ref$arrow,
25
- spotlight = _ref.spotlight,
26
- onClick = _ref.onClick,
27
- children = _ref.children,
28
- loading = _ref.loading,
29
- props = _objectWithoutProperties(_ref, _excluded);
30
- var _useStyles = useStyles({
31
- active: Boolean(active),
32
- glass: Boolean(glass)
33
- }),
34
- styles = _useStyles.styles,
35
- cx = _useStyles.cx;
13
+ var calcSize = function calcSize(size) {
36
14
  var blockSize;
37
15
  var borderRadius;
38
16
  switch (size) {
@@ -57,6 +35,39 @@ var ActionIcon = /*#__PURE__*/memo(function (_ref) {
57
35
  borderRadius = (size === null || size === void 0 ? void 0 : size.borderRadius) || 5;
58
36
  break;
59
37
  }
38
+ return {
39
+ blockSize: blockSize,
40
+ borderRadius: borderRadius
41
+ };
42
+ };
43
+ var ActionIcon = /*#__PURE__*/memo(function (_ref) {
44
+ var className = _ref.className,
45
+ active = _ref.active,
46
+ icon = _ref.icon,
47
+ _ref$size = _ref.size,
48
+ size = _ref$size === void 0 ? 'normal' : _ref$size,
49
+ style = _ref.style,
50
+ glass = _ref.glass,
51
+ title = _ref.title,
52
+ placement = _ref.placement,
53
+ _ref$arrow = _ref.arrow,
54
+ arrow = _ref$arrow === void 0 ? false : _ref$arrow,
55
+ spotlight = _ref.spotlight,
56
+ onClick = _ref.onClick,
57
+ children = _ref.children,
58
+ loading = _ref.loading,
59
+ props = _objectWithoutProperties(_ref, _excluded);
60
+ var _useStyles = useStyles({
61
+ active: Boolean(active),
62
+ glass: Boolean(glass)
63
+ }),
64
+ styles = _useStyles.styles,
65
+ cx = _useStyles.cx;
66
+ var _useMemo = useMemo(function () {
67
+ return calcSize(size);
68
+ }, [size]),
69
+ blockSize = _useMemo.blockSize,
70
+ borderRadius = _useMemo.borderRadius;
60
71
  var content = /*#__PURE__*/_jsxs(_Fragment, {
61
72
  children: [icon && /*#__PURE__*/_jsx(Icon, {
62
73
  icon: icon,
@@ -1,5 +1,6 @@
1
- import { FC } from 'react';
2
- export interface AvatarProps {
1
+ /// <reference types="react" />
2
+ import { type AvatarProps as AntAvatarProps } from 'antd';
3
+ export interface AvatarProps extends AntAvatarProps {
3
4
  /**
4
5
  * @description The URL or base64 data of the avatar image
5
6
  */
@@ -23,5 +24,5 @@ export interface AvatarProps {
23
24
  */
24
25
  title?: string;
25
26
  }
26
- declare const Avatar: FC<AvatarProps>;
27
+ declare const Avatar: import("react").NamedExoticComponent<AvatarProps>;
27
28
  export default Avatar;
@@ -1,51 +1,43 @@
1
- import { Avatar as A } from 'antd';
2
- import { Center } from 'react-layout-kit';
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["className", "avatar", "title", "size", "shape", "background"];
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
+ import { Avatar as AntAvatar } from 'antd';
7
+ import { memo } from 'react';
3
8
  import { useStyles } from "./style";
4
9
  import { jsx as _jsx } from "react/jsx-runtime";
5
- var Avatar = function Avatar(_ref) {
6
- var avatar = _ref.avatar,
10
+ var Avatar = /*#__PURE__*/memo(function (_ref) {
11
+ var className = _ref.className,
12
+ avatar = _ref.avatar,
7
13
  title = _ref.title,
8
14
  _ref$size = _ref.size,
9
15
  size = _ref$size === void 0 ? 40 : _ref$size,
10
16
  _ref$shape = _ref.shape,
11
17
  shape = _ref$shape === void 0 ? 'circle' : _ref$shape,
12
- background = _ref.background;
13
- var _useStyles = useStyles(),
18
+ background = _ref.background,
19
+ props = _objectWithoutProperties(_ref, _excluded);
20
+ var _useStyles = useStyles({
21
+ background: background,
22
+ size: size
23
+ }),
14
24
  styles = _useStyles.styles,
15
- theme = _useStyles.theme;
16
- var backgroundColor = background !== null && background !== void 0 ? background : theme.colorBgContainer;
25
+ cx = _useStyles.cx;
17
26
  var isImage = avatar && ['/', 'http', 'data:'].some(function (i) {
18
27
  return avatar.startsWith(i);
19
28
  });
20
- return /*#__PURE__*/_jsx(Center, {
21
- className: styles.container,
22
- style: {
23
- width: size,
24
- height: size,
25
- borderRadius: shape === 'circle' ? '50%' : 6,
26
- backgroundColor: backgroundColor,
27
- borderWidth: isImage ? 1 : 0
28
- },
29
- children: !avatar ? /*#__PURE__*/_jsx(A, {
30
- shape: shape,
31
- size: size,
32
- children: title === null || title === void 0 ? void 0 : title.slice(0, 2)
33
- }) : isImage ? /*#__PURE__*/_jsx(A, {
34
- className: styles.border,
35
- shape: shape,
36
- size: size,
37
- src: avatar
38
- }) : /*#__PURE__*/_jsx(Center, {
39
- className: styles.border,
40
- style: {
41
- width: size,
42
- height: size,
43
- fontSize: size / 2,
44
- borderRadius: shape === 'circle' ? '50%' : 6,
45
- backgroundColor: backgroundColor
46
- },
47
- children: avatar
48
- })
49
- });
50
- };
29
+ var text = isImage ? title : avatar;
30
+ return !isImage ? /*#__PURE__*/_jsx(AntAvatar, _objectSpread(_objectSpread({
31
+ className: cx(styles.avatar, className),
32
+ shape: shape,
33
+ size: size
34
+ }, props), {}, {
35
+ children: text === null || text === void 0 ? void 0 : text.toUpperCase().slice(0, 2)
36
+ })) : /*#__PURE__*/_jsx(AntAvatar, _objectSpread({
37
+ className: cx(styles.avatar, className),
38
+ shape: shape,
39
+ size: size,
40
+ src: avatar
41
+ }, props));
42
+ });
51
43
  export default Avatar;
@@ -1,4 +1,6 @@
1
- export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
2
- container: import("antd-style").SerializedStyles;
3
- border: import("antd-style").SerializedStyles;
1
+ export declare const useStyles: (props?: {
2
+ background?: string | undefined;
3
+ size: number;
4
+ } | undefined) => import("antd-style").ReturnStyles<{
5
+ avatar: import("antd-style").SerializedStyles;
4
6
  }>;
@@ -1,11 +1,15 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
- var _templateObject, _templateObject2;
2
+ var _templateObject;
3
3
  import { createStyles } from 'antd-style';
4
- export var useStyles = createStyles(function (_ref) {
4
+ import { readableColor } from 'polished';
5
+ export var useStyles = createStyles(function (_ref, _ref2) {
5
6
  var css = _ref.css,
6
7
  token = _ref.token;
8
+ var background = _ref2.background,
9
+ size = _ref2.size;
10
+ var backgroundColor = background !== null && background !== void 0 ? background : token.colorBgContainer;
11
+ var color = readableColor(backgroundColor);
7
12
  return {
8
- container: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: pointer;\n\n > * {\n cursor: pointer;\n }\n "]))),
9
- border: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n border: 1px solid ", ";\n "])), token.colorSplit)
13
+ avatar: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: pointer;\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n background: ", ";\n border: 1px solid ", ";\n\n > .ant-avatar-string {\n font-size: ", "px;\n font-weight: 700;\n line-height: 1 !important;\n color: ", ";\n }\n\n > * {\n cursor: pointer;\n }\n "])), backgroundColor, background ? 'transparent' : token.colorSplit, size * 0.5, color)
10
14
  };
11
15
  });
@@ -0,0 +1,48 @@
1
+ /// <reference types="react" />
2
+ import { type AlertProps } from 'antd';
3
+ import type { DivProps } from "../types";
4
+ export interface ChatItemProps extends DivProps {
5
+ /**
6
+ * @description Weather to show alert and alert config
7
+ */
8
+ alert?: AlertProps;
9
+ /**
10
+ * @description URL of the avatar image
11
+ */
12
+ avatar?: string;
13
+ /**
14
+ * @description Whether to add spacing between chat items
15
+ * @default true
16
+ */
17
+ borderSpacing?: boolean;
18
+ /**
19
+ * @description Whether to show a loading spinner
20
+ * @default false
21
+ */
22
+ loading?: boolean;
23
+ /**
24
+ * @description The message to be displayed
25
+ */
26
+ message?: string;
27
+ /**
28
+ * @description The name of the chat item
29
+ */
30
+ name?: string;
31
+ /**
32
+ * @description The placement of the chat item
33
+ * @default 'left'
34
+ */
35
+ placement?: 'left' | 'right';
36
+ /**
37
+ * @description Whether the chat item is primary
38
+ * @default false
39
+ */
40
+ primary?: boolean;
41
+ /**
42
+ * @description The type of chat item
43
+ * @default 'block'
44
+ */
45
+ type?: 'block' | 'pure';
46
+ }
47
+ declare const ChatItem: import("react").NamedExoticComponent<ChatItemProps>;
48
+ export default ChatItem;
@@ -0,0 +1,78 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["className", "name", "primary", "borderSpacing", "loading", "message", "placement", "type", "avatar", "alert"];
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
+ import { Alert } from 'antd';
7
+ import { Loader2 } from 'lucide-react';
8
+ import { memo } from 'react';
9
+ import { Avatar, Icon, Markdown } from "./..";
10
+ import { useStyles } from "./style";
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ import { jsxs as _jsxs } from "react/jsx-runtime";
13
+ var AVATAR_SIZE = 40;
14
+ var ChatItem = /*#__PURE__*/memo(function (_ref) {
15
+ var className = _ref.className,
16
+ name = _ref.name,
17
+ primary = _ref.primary,
18
+ _ref$borderSpacing = _ref.borderSpacing,
19
+ borderSpacing = _ref$borderSpacing === void 0 ? true : _ref$borderSpacing,
20
+ loading = _ref.loading,
21
+ message = _ref.message,
22
+ _ref$placement = _ref.placement,
23
+ placement = _ref$placement === void 0 ? 'left' : _ref$placement,
24
+ _ref$type = _ref.type,
25
+ type = _ref$type === void 0 ? 'block' : _ref$type,
26
+ avatar = _ref.avatar,
27
+ alert = _ref.alert,
28
+ props = _objectWithoutProperties(_ref, _excluded);
29
+ var _useStyles = useStyles({
30
+ placement: placement,
31
+ type: type,
32
+ name: name,
33
+ primary: primary,
34
+ avatarSize: AVATAR_SIZE
35
+ }),
36
+ cx = _useStyles.cx,
37
+ styles = _useStyles.styles;
38
+ return /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({
39
+ className: cx(styles.container, className)
40
+ }, props), {}, {
41
+ children: [/*#__PURE__*/_jsxs("div", {
42
+ className: styles.avatarContainer,
43
+ children: [/*#__PURE__*/_jsx(Avatar, {
44
+ avatar: avatar,
45
+ size: AVATAR_SIZE
46
+ }), loading && /*#__PURE__*/_jsx("div", {
47
+ className: styles.loading,
48
+ children: /*#__PURE__*/_jsx(Icon, {
49
+ icon: Loader2,
50
+ size: {
51
+ fontSize: 12,
52
+ strokeWidth: 3
53
+ },
54
+ spin: true
55
+ })
56
+ })]
57
+ }), /*#__PURE__*/_jsxs("div", {
58
+ className: styles.messageContainer,
59
+ children: [name && /*#__PURE__*/_jsx("div", {
60
+ className: styles.name,
61
+ children: name
62
+ }), alert ? /*#__PURE__*/_jsx(Alert, _objectSpread({
63
+ showIcon: true
64
+ }, alert)) : /*#__PURE__*/_jsx("div", {
65
+ className: styles.message,
66
+ children: /*#__PURE__*/_jsx(Markdown, {
67
+ children: String(message || '...')
68
+ })
69
+ })]
70
+ }), borderSpacing && /*#__PURE__*/_jsx("div", {
71
+ style: {
72
+ width: AVATAR_SIZE,
73
+ flex: 'none'
74
+ }
75
+ })]
76
+ }));
77
+ });
78
+ export default ChatItem;
@@ -0,0 +1,14 @@
1
+ export declare const useStyles: (props?: {
2
+ avatarSize: number;
3
+ name?: string | undefined;
4
+ placement?: "left" | "right" | undefined;
5
+ primary?: boolean | undefined;
6
+ type?: "block" | "pure" | undefined;
7
+ } | undefined) => import("antd-style").ReturnStyles<{
8
+ container: string;
9
+ loading: import("antd-style").SerializedStyles;
10
+ avatarContainer: import("antd-style").SerializedStyles;
11
+ messageContainer: import("antd-style").SerializedStyles;
12
+ name: import("antd-style").SerializedStyles;
13
+ message: string;
14
+ }>;
@@ -0,0 +1,25 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
3
+ import { createStyles } from 'antd-style';
4
+ export var useStyles = createStyles(function (_ref, _ref2) {
5
+ var cx = _ref.cx,
6
+ css = _ref.css,
7
+ token = _ref.token;
8
+ var placement = _ref2.placement,
9
+ type = _ref2.type,
10
+ name = _ref2.name,
11
+ primary = _ref2.primary,
12
+ avatarSize = _ref2.avatarSize;
13
+ 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);
14
+ var pureStylish = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding-top: ", ";\n "])), name ? 0 : '6px');
15
+ 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);
16
+ var typeStylish = type === 'block' ? blockStylish : pureStylish;
17
+ return {
18
+ 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 "])), placement === 'left' ? 'row' : 'row-reverse')),
19
+ 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),
20
+ avatarContainer: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n position: relative;\n flex: none;\n width: ", "px;\n height: ", "px;\n "])), avatarSize, avatarSize),
21
+ messageContainer: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n position: relative;\n\n .ant-alert-with-description {\n padding-block: 12px;\n padding-inline: 12px;\n }\n "]))),
22
+ name: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n margin-bottom: 6px;\n\n font-size: 12px;\n line-height: 1;\n color: ", ";\n text-align: ", ";\n "])), token.colorTextDescription, placement === 'left' ? 'left' : 'right'),
23
+ message: cx(typeStylish, css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n position: relative;\n "]))))
24
+ };
25
+ });
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" />
2
+ import { ChatMessage } from "../Chat";
3
+ import type { DivProps } from "../types";
4
+ export interface ChatListProps extends DivProps {
5
+ /**
6
+ * @description Data of chat messages to be displayed
7
+ */
8
+ data: ChatMessage[];
9
+ /**
10
+ * @description Type of chat list
11
+ * @default 'chat'
12
+ */
13
+ type?: 'docs' | 'chat';
14
+ }
15
+ declare const ChatList: import("react").NamedExoticComponent<ChatListProps>;
16
+ export default ChatList;
@@ -0,0 +1,33 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["className", "data", "type"];
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
+ import { memo } from 'react';
7
+ import { ChatItem } from "./..";
8
+ import { useStyles } from "./style";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ var ChatList = /*#__PURE__*/memo(function (_ref) {
11
+ var className = _ref.className,
12
+ data = _ref.data,
13
+ _ref$type = _ref.type,
14
+ type = _ref$type === void 0 ? 'chat' : _ref$type,
15
+ props = _objectWithoutProperties(_ref, _excluded);
16
+ var _useStyles = useStyles(),
17
+ cx = _useStyles.cx,
18
+ styles = _useStyles.styles;
19
+ return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({
20
+ className: cx(styles.container, className)
21
+ }, props), {}, {
22
+ children: data.map(function (item, index) {
23
+ return /*#__PURE__*/_jsx(ChatItem, {
24
+ borderSpacing: type === 'chat',
25
+ message: item.content,
26
+ placement: type === 'chat' ? item.role === 'user' ? 'right' : 'left' : 'left',
27
+ primary: item.role === 'user',
28
+ type: type === 'chat' ? 'block' : 'pure'
29
+ }, index);
30
+ })
31
+ }));
32
+ });
33
+ export default ChatList;
@@ -0,0 +1,3 @@
1
+ export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
2
+ container: import("antd-style").SerializedStyles;
3
+ }>;
@@ -0,0 +1,9 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject;
3
+ import { createStyles } from 'antd-style';
4
+ export var useStyles = createStyles(function (_ref) {
5
+ var css = _ref.css;
6
+ return {
7
+ container: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n "])))
8
+ };
9
+ });
@@ -30,7 +30,7 @@ export interface HighlighterProps extends DivProps {
30
30
  * @description The type of the code block
31
31
  * @default 'block'
32
32
  */
33
- type?: 'ghost' | 'block' | 'prue';
33
+ type?: 'ghost' | 'block' | 'pure';
34
34
  }
35
35
  export declare const Highlighter: import("react").NamedExoticComponent<HighlighterProps>;
36
36
  export default Highlighter;
@@ -1,4 +1,4 @@
1
- export declare const useStyles: (props?: "block" | "ghost" | "prue" | undefined) => import("antd-style").ReturnStyles<{
1
+ export declare const useStyles: (props?: "block" | "pure" | "ghost" | undefined) => import("antd-style").ReturnStyles<{
2
2
  container: string;
3
3
  button: string;
4
4
  lang: string;
@@ -9,9 +9,9 @@ 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 === 'prue' ? '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 === 'pure' ? 'transparent' : token.colorFillTertiary);
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 === 'prue' ? 0 : "16px 24px")),
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
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 "])))),
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
  };
package/es/Icon/index.js CHANGED
@@ -3,20 +3,10 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
3
3
  var _excluded = ["icon", "size", "style", "className", "spin"];
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
- import { memo } from 'react';
6
+ import { memo, useMemo } from 'react';
7
7
  import { useStyles } from "./style";
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
- var Icon = /*#__PURE__*/memo(function (_ref) {
10
- var icon = _ref.icon,
11
- size = _ref.size,
12
- style = _ref.style,
13
- className = _ref.className,
14
- spin = _ref.spin,
15
- props = _objectWithoutProperties(_ref, _excluded);
16
- var _useStyles = useStyles(),
17
- styles = _useStyles.styles,
18
- cx = _useStyles.cx;
19
- var SvgIcon = icon;
9
+ var calcSize = function calcSize(size) {
20
10
  var fontSize;
21
11
  var strokeWidth;
22
12
  switch (size) {
@@ -42,8 +32,29 @@ var Icon = /*#__PURE__*/memo(function (_ref) {
42
32
  }
43
33
  break;
44
34
  }
35
+ return {
36
+ fontSize: fontSize,
37
+ strokeWidth: strokeWidth
38
+ };
39
+ };
40
+ var Icon = /*#__PURE__*/memo(function (_ref) {
41
+ var icon = _ref.icon,
42
+ size = _ref.size,
43
+ style = _ref.style,
44
+ className = _ref.className,
45
+ spin = _ref.spin,
46
+ props = _objectWithoutProperties(_ref, _excluded);
47
+ var _useStyles = useStyles(),
48
+ styles = _useStyles.styles,
49
+ cx = _useStyles.cx;
50
+ var SvgIcon = icon;
51
+ var _useMemo = useMemo(function () {
52
+ return calcSize(size);
53
+ }, [size]),
54
+ fontSize = _useMemo.fontSize,
55
+ strokeWidth = _useMemo.strokeWidth;
45
56
  return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({
46
- className: cx(spin && styles.spin, className),
57
+ className: cx(styles.icon, spin && styles.spin, className),
47
58
  style: _objectSpread({
48
59
  width: fontSize,
49
60
  height: fontSize
@@ -1,3 +1,4 @@
1
1
  export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
2
+ icon: import("antd-style").SerializedStyles;
2
3
  spin: import("antd-style").SerializedStyles;
3
4
  }>;
package/es/Icon/style.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
- var _templateObject, _templateObject2;
2
+ var _templateObject, _templateObject2, _templateObject3;
3
3
  import { createStyles, keyframes } from 'antd-style';
4
4
  export var useStyles = createStyles(function (_ref) {
5
5
  var css = _ref.css;
6
6
  var spin = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n "])));
7
7
  return {
8
- spin: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n animation: ", " 1s linear infinite;\n "])), spin)
8
+ icon: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n justify-content: center;\n "]))),
9
+ spin: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n animation: ", " 1s linear infinite;\n "])), spin)
9
10
  };
10
11
  });
package/es/Input/style.js CHANGED
@@ -8,7 +8,7 @@ export var useStyles = createStyles(function (_ref, _ref2) {
8
8
  var type = _ref2.type;
9
9
  var typeStylish = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n border: 1px solid ", ";\n "])), type === 'block' ? token.colorFillTertiary : 'transparent', type === 'block' ? 'transparent' : token.colorBorder);
10
10
  return {
11
- input: cx(typeStylish, css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n\n max-width: 100%;\n height: 36px;\n padding: 0 12px;\n\n transition: background-color 100ms ", ";\n\n input {\n background: transparent;\n }\n\n &:hover {\n background-color: ", ";\n border-color: ", ";\n }\n\n &:focus {\n border-color: ", ";\n }\n "])), token.motionEaseOut, token.colorFillTertiary, token.colorBorder, token.colorTextQuaternary)),
11
+ input: cx(typeStylish, css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n\n max-width: 100%;\n height: 36px;\n padding: 0 12px;\n\n transition: background-color 100ms ", ",\n border-color 200ms ", ";\n\n input {\n background: transparent;\n }\n\n &:hover {\n background-color: ", ";\n }\n\n &:focus {\n border-color: ", ";\n }\n\n &.ant-input-affix-wrapper-focused {\n border-color: ", ";\n }\n "])), token.motionEaseOut, token.motionEaseOut, token.colorFillTertiary, token.colorTextQuaternary, token.colorTextQuaternary)),
12
12
  textarea: cx(typeStylish, css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: relative;\n max-width: 100%;\n padding: 8px 12px;\n transition: background-color 100ms ", ";\n\n textarea {\n background: transparent;\n }\n\n &:hover {\n background-color: ", ";\n border-color: ", ";\n }\n\n &:focus {\n border-color: ", ";\n }\n "])), token.motionEaseOut, token.colorFillTertiary, token.colorBorder, token.colorTextQuaternary))
13
13
  };
14
14
  });
@@ -5,7 +5,7 @@ export var useStyles = createStyles(function (_ref) {
5
5
  var css = _ref.css,
6
6
  token = _ref.token;
7
7
  return {
8
- search: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n max-width: 100%;\n\n .ant-input-affix-wrapper {\n &:hover {\n border-color: ", ";\n }\n }\n\n .ant-input-affix-wrapper-focused {\n border-color: ", ";\n\n &:hover {\n border-color: ", ";\n }\n }\n "])), token.colorBorder, token.colorTextQuaternary, token.colorTextQuaternary),
8
+ search: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n max-width: 100%;\n "]))),
9
9
  input: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n padding: 0 8px 0 12px;\n "]))),
10
10
  tag: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n pointer-events: none;\n\n position: absolute;\n z-index: 5;\n top: 50%;\n right: 0;\n transform: translateY(-50%);\n "]))),
11
11
  icon: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n color: ", ";\n "])), token.colorTextPlaceholder)
package/es/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export { default as ActionIcon, type ActionIconProps, type ActionIconSize } from './ActionIcon';
2
2
  export { default as Avatar, type AvatarProps } from './Avatar';
3
3
  export type { ChatMessage, MessageRoleType } from './Chat';
4
+ export { default as ChatItem, type ChatItemProps } from './ChatItem';
5
+ export { default as ChatList, type ChatListProps } from './ChatList';
4
6
  export { default as ColorScales, type ColorScalesProps } from './ColorScales';
5
7
  export { default as ContextMenu, type ContextMenuProps } from './ContextMenu';
6
8
  export { default as Conversation, type ConversationProps } from './Conversation';
package/es/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  export { default as ActionIcon } from "./ActionIcon";
2
2
  export { default as Avatar } from "./Avatar";
3
+ export { default as ChatItem } from "./ChatItem";
4
+ export { default as ChatList } from "./ChatList";
3
5
  export { default as ColorScales } from "./ColorScales";
4
6
  export { default as ContextMenu } from "./ContextMenu";
5
7
  export { default as Conversation } from "./Conversation";
@@ -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: 20px auto;\n\n font-size: 14px;\n line-height: 1.8;\n color: ", ";\n text-align: justify;\n word-wrap: break-word;\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-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.20.0",
3
+ "version": "1.21.0",
4
4
  "description": "Lobe UI is an open-source UI component library for building chatbot web apps",
5
5
  "keywords": [
6
6
  "lobehub",
@@ -114,7 +114,6 @@
114
114
  "antd": "^5",
115
115
  "antd-style": "^3",
116
116
  "commitlint": "^17",
117
- "commitlint-config-gitmoji": "^2",
118
117
  "concurrently": "^8",
119
118
  "cross-env": "^7",
120
119
  "dumi": "^2",