@lobehub/ui 1.21.0 → 1.22.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.
- package/es/ActionIcon/index.js +4 -0
- package/es/ActionIconGroup/index.d.ts +24 -0
- package/es/ActionIconGroup/index.js +37 -0
- package/es/ActionIconGroup/style.d.ts +6 -0
- package/es/ActionIconGroup/style.js +15 -0
- package/es/Avatar/index.js +7 -5
- package/es/Avatar/style.d.ts +1 -0
- package/es/Avatar/style.js +3 -2
- package/es/ChatItem/index.d.ts +13 -7
- package/es/ChatItem/index.js +18 -9
- package/es/ChatItem/style.d.ts +3 -1
- package/es/ChatItem/style.js +11 -8
- package/es/ChatList/index.d.ts +7 -1
- package/es/ChatList/index.js +7 -3
- package/es/Highlighter/style.d.ts +1 -1
- package/es/Menu/MenuItem/icons.d.ts +4 -0
- package/es/Menu/MenuItem/icons.js +73 -0
- package/es/Menu/MenuItem/index.d.ts +12 -0
- package/es/Menu/MenuItem/index.js +73 -0
- package/es/Menu/MenuItem/style.d.ts +7 -0
- package/es/Menu/MenuItem/style.js +16 -0
- package/es/Menu/index.d.ts +17 -0
- package/es/Menu/index.js +248 -0
- package/es/Menu/style.d.ts +4 -0
- package/es/Menu/style.js +12 -0
- package/es/Menu/types/index.d.ts +5 -0
- package/es/Menu/types/index.js +2 -0
- package/es/Menu/types/menuItem.d.ts +21 -0
- package/es/Menu/types/menuItem.js +1 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/types/chatMessage.d.ts +33 -0
- package/es/types/chatMessage.js +1 -0
- package/es/types/llm.d.ts +42 -0
- package/es/types/llm.js +10 -0
- package/es/types/meta.d.ts +25 -0
- package/es/types/meta.js +1 -0
- package/es/utils/formatTime.d.ts +1 -0
- package/es/utils/formatTime.js +12 -0
- package/package.json +1 -1
package/es/ActionIcon/index.js
CHANGED
|
@@ -93,6 +93,10 @@ var ActionIcon = /*#__PURE__*/memo(function (_ref) {
|
|
|
93
93
|
if (!title) return actionIconBlock;
|
|
94
94
|
return /*#__PURE__*/_jsx(Tooltip, {
|
|
95
95
|
arrow: arrow,
|
|
96
|
+
mouseEnterDelay: 1,
|
|
97
|
+
overlayStyle: {
|
|
98
|
+
pointerEvents: 'none'
|
|
99
|
+
},
|
|
96
100
|
placement: placement,
|
|
97
101
|
title: title,
|
|
98
102
|
children: actionIconBlock
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ActionIconProps } from "..";
|
|
3
|
+
import { DivProps } from "../types";
|
|
4
|
+
export interface ActionIconGroupProps extends DivProps {
|
|
5
|
+
direction?: 'row' | 'column';
|
|
6
|
+
items: ActionIconProps[];
|
|
7
|
+
/**
|
|
8
|
+
* @description The position of the tooltip relative to the target
|
|
9
|
+
* @enum ["top","left","right","bottom","topLeft","topRight","bottomLeft","bottomRight","leftTop","leftBottom","rightTop","rightBottom"]
|
|
10
|
+
*/
|
|
11
|
+
placement?: ActionIconProps['placement'];
|
|
12
|
+
/**
|
|
13
|
+
* @description Whether add spotlight background
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
spotlight?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* @description The type of the group
|
|
19
|
+
* @default 'block'
|
|
20
|
+
*/
|
|
21
|
+
type?: 'ghost' | 'block' | 'pure';
|
|
22
|
+
}
|
|
23
|
+
declare const ActionIconGroup: import("react").NamedExoticComponent<ActionIconGroupProps>;
|
|
24
|
+
export default ActionIconGroup;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["type", "items", "placement", "spotlight", "direction"];
|
|
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 { ActionIcon, Spotlight } from "./..";
|
|
7
|
+
import { memo } from 'react';
|
|
8
|
+
import { useStyles } from "./style";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
var ActionIconGroup = /*#__PURE__*/memo(function (_ref) {
|
|
12
|
+
var _ref$type = _ref.type,
|
|
13
|
+
type = _ref$type === void 0 ? 'block' : _ref$type,
|
|
14
|
+
items = _ref.items,
|
|
15
|
+
placement = _ref.placement,
|
|
16
|
+
_ref$spotlight = _ref.spotlight,
|
|
17
|
+
spotlight = _ref$spotlight === void 0 ? true : _ref$spotlight,
|
|
18
|
+
_ref$direction = _ref.direction,
|
|
19
|
+
direction = _ref$direction === void 0 ? 'row' : _ref$direction,
|
|
20
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
21
|
+
var _useStyles = useStyles({
|
|
22
|
+
direction: direction,
|
|
23
|
+
type: type
|
|
24
|
+
}),
|
|
25
|
+
styles = _useStyles.styles;
|
|
26
|
+
return /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({
|
|
27
|
+
className: styles.container
|
|
28
|
+
}, props), {}, {
|
|
29
|
+
children: [spotlight && /*#__PURE__*/_jsx(Spotlight, {}), items.map(function (item, index) {
|
|
30
|
+
return /*#__PURE__*/_jsx(ActionIcon, _objectSpread({
|
|
31
|
+
placement: placement || (direction === 'column' ? 'right' : 'top'),
|
|
32
|
+
size: "small"
|
|
33
|
+
}, item), index);
|
|
34
|
+
})]
|
|
35
|
+
}));
|
|
36
|
+
});
|
|
37
|
+
export default ActionIconGroup;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2;
|
|
3
|
+
import { createStyles } from 'antd-style';
|
|
4
|
+
export var useStyles = createStyles(function (_ref, _ref2) {
|
|
5
|
+
var css = _ref.css,
|
|
6
|
+
token = _ref.token,
|
|
7
|
+
stylish = _ref.stylish,
|
|
8
|
+
cx = _ref.cx;
|
|
9
|
+
var direction = _ref2.direction,
|
|
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);
|
|
12
|
+
return {
|
|
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
|
+
};
|
|
15
|
+
});
|
package/es/Avatar/index.js
CHANGED
|
@@ -17,22 +17,24 @@ 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) {
|
|
21
|
+
return avatar.startsWith(i);
|
|
22
|
+
});
|
|
23
|
+
var isEmoji = avatar && !isImage && /\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDE4F]/g.test(avatar);
|
|
20
24
|
var _useStyles = useStyles({
|
|
21
25
|
background: background,
|
|
22
|
-
size: size
|
|
26
|
+
size: size,
|
|
27
|
+
isEmoji: isEmoji
|
|
23
28
|
}),
|
|
24
29
|
styles = _useStyles.styles,
|
|
25
30
|
cx = _useStyles.cx;
|
|
26
|
-
var isImage = avatar && ['/', 'http', 'data:'].some(function (i) {
|
|
27
|
-
return avatar.startsWith(i);
|
|
28
|
-
});
|
|
29
31
|
var text = isImage ? title : avatar;
|
|
30
32
|
return !isImage ? /*#__PURE__*/_jsx(AntAvatar, _objectSpread(_objectSpread({
|
|
31
33
|
className: cx(styles.avatar, className),
|
|
32
34
|
shape: shape,
|
|
33
35
|
size: size
|
|
34
36
|
}, props), {}, {
|
|
35
|
-
children: text === null || text === void 0 ? void 0 : text.toUpperCase().slice(0, 2)
|
|
37
|
+
children: isEmoji ? text : text === null || text === void 0 ? void 0 : text.toUpperCase().slice(0, 2)
|
|
36
38
|
})) : /*#__PURE__*/_jsx(AntAvatar, _objectSpread({
|
|
37
39
|
className: cx(styles.avatar, className),
|
|
38
40
|
shape: shape,
|
package/es/Avatar/style.d.ts
CHANGED
package/es/Avatar/style.js
CHANGED
|
@@ -6,10 +6,11 @@ export var useStyles = createStyles(function (_ref, _ref2) {
|
|
|
6
6
|
var css = _ref.css,
|
|
7
7
|
token = _ref.token;
|
|
8
8
|
var background = _ref2.background,
|
|
9
|
-
size = _ref2.size
|
|
9
|
+
size = _ref2.size,
|
|
10
|
+
isEmoji = _ref2.isEmoji;
|
|
10
11
|
var backgroundColor = background !== null && background !== void 0 ? background : token.colorBgContainer;
|
|
11
12
|
var color = readableColor(backgroundColor);
|
|
12
13
|
return {
|
|
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)
|
|
14
|
+
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 * (isEmoji ? 0.7 : 0.5), color)
|
|
14
15
|
};
|
|
15
16
|
});
|
package/es/ChatItem/index.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { type AlertProps } from 'antd';
|
|
3
3
|
import type { DivProps } from "../types";
|
|
4
|
+
import { MetaData } from "../types/meta";
|
|
4
5
|
export interface ChatItemProps extends DivProps {
|
|
5
6
|
/**
|
|
6
|
-
* @description
|
|
7
|
+
* @description Whether to show alert and alert config
|
|
7
8
|
*/
|
|
8
9
|
alert?: AlertProps;
|
|
9
10
|
/**
|
|
10
|
-
* @description
|
|
11
|
+
* @description Avatar config
|
|
11
12
|
*/
|
|
12
|
-
avatar
|
|
13
|
+
avatar: MetaData;
|
|
13
14
|
/**
|
|
14
15
|
* @description Whether to add spacing between chat items
|
|
15
16
|
* @default true
|
|
@@ -24,10 +25,6 @@ export interface ChatItemProps extends DivProps {
|
|
|
24
25
|
* @description The message to be displayed
|
|
25
26
|
*/
|
|
26
27
|
message?: string;
|
|
27
|
-
/**
|
|
28
|
-
* @description The name of the chat item
|
|
29
|
-
*/
|
|
30
|
-
name?: string;
|
|
31
28
|
/**
|
|
32
29
|
* @description The placement of the chat item
|
|
33
30
|
* @default 'left'
|
|
@@ -38,6 +35,15 @@ export interface ChatItemProps extends DivProps {
|
|
|
38
35
|
* @default false
|
|
39
36
|
*/
|
|
40
37
|
primary?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* @description Whether to show name of the chat item
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
showTitle?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* @description Time of chat message
|
|
45
|
+
*/
|
|
46
|
+
time?: number;
|
|
41
47
|
/**
|
|
42
48
|
* @description The type of chat item
|
|
43
49
|
* @default 'block'
|
package/es/ChatItem/index.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["className", "
|
|
3
|
+
var _excluded = ["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';
|
|
7
7
|
import { Loader2 } from 'lucide-react';
|
|
8
8
|
import { memo } from 'react';
|
|
9
9
|
import { Avatar, Icon, Markdown } from "./..";
|
|
10
|
+
import { formatTime } from "../utils/formatTime";
|
|
10
11
|
import { useStyles } from "./style";
|
|
11
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
13
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
14
|
var AVATAR_SIZE = 40;
|
|
14
15
|
var ChatItem = /*#__PURE__*/memo(function (_ref) {
|
|
15
16
|
var className = _ref.className,
|
|
16
|
-
|
|
17
|
+
title = _ref.title,
|
|
17
18
|
primary = _ref.primary,
|
|
18
19
|
_ref$borderSpacing = _ref.borderSpacing,
|
|
19
20
|
borderSpacing = _ref$borderSpacing === void 0 ? true : _ref$borderSpacing,
|
|
@@ -25,13 +26,16 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
|
|
|
25
26
|
type = _ref$type === void 0 ? 'block' : _ref$type,
|
|
26
27
|
avatar = _ref.avatar,
|
|
27
28
|
alert = _ref.alert,
|
|
29
|
+
showTitle = _ref.showTitle,
|
|
30
|
+
time = _ref.time,
|
|
28
31
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
29
32
|
var _useStyles = useStyles({
|
|
30
33
|
placement: placement,
|
|
31
34
|
type: type,
|
|
32
|
-
|
|
35
|
+
title: title,
|
|
33
36
|
primary: primary,
|
|
34
|
-
avatarSize: AVATAR_SIZE
|
|
37
|
+
avatarSize: AVATAR_SIZE,
|
|
38
|
+
showTitle: showTitle
|
|
35
39
|
}),
|
|
36
40
|
cx = _useStyles.cx,
|
|
37
41
|
styles = _useStyles.styles;
|
|
@@ -41,8 +45,10 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
|
|
|
41
45
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
42
46
|
className: styles.avatarContainer,
|
|
43
47
|
children: [/*#__PURE__*/_jsx(Avatar, {
|
|
44
|
-
avatar: avatar,
|
|
45
|
-
|
|
48
|
+
avatar: avatar.avatar,
|
|
49
|
+
background: avatar.backgroundColor,
|
|
50
|
+
size: AVATAR_SIZE,
|
|
51
|
+
title: avatar.title
|
|
46
52
|
}), loading && /*#__PURE__*/_jsx("div", {
|
|
47
53
|
className: styles.loading,
|
|
48
54
|
children: /*#__PURE__*/_jsx(Icon, {
|
|
@@ -56,9 +62,12 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
|
|
|
56
62
|
})]
|
|
57
63
|
}), /*#__PURE__*/_jsxs("div", {
|
|
58
64
|
className: styles.messageContainer,
|
|
59
|
-
children: [
|
|
60
|
-
className: styles.name,
|
|
61
|
-
children:
|
|
65
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
66
|
+
className: cx(styles.name, 'chat-item-name'),
|
|
67
|
+
children: [showTitle ? avatar.title || 'untitled' : null, time && /*#__PURE__*/_jsx("span", {
|
|
68
|
+
className: cx(type === 'pure' && !showTitle && styles.time, 'chat-item-time'),
|
|
69
|
+
children: formatTime(time)
|
|
70
|
+
})]
|
|
62
71
|
}), alert ? /*#__PURE__*/_jsx(Alert, _objectSpread({
|
|
63
72
|
showIcon: true
|
|
64
73
|
}, alert)) : /*#__PURE__*/_jsx("div", {
|
package/es/ChatItem/style.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export declare const useStyles: (props?: {
|
|
2
2
|
avatarSize: number;
|
|
3
|
-
name?: string | undefined;
|
|
4
3
|
placement?: "left" | "right" | undefined;
|
|
5
4
|
primary?: boolean | undefined;
|
|
5
|
+
showTitle?: boolean | undefined;
|
|
6
|
+
title?: string | undefined;
|
|
6
7
|
type?: "block" | "pure" | undefined;
|
|
7
8
|
} | undefined) => import("antd-style").ReturnStyles<{
|
|
8
9
|
container: string;
|
|
@@ -10,5 +11,6 @@ export declare const useStyles: (props?: {
|
|
|
10
11
|
avatarContainer: import("antd-style").SerializedStyles;
|
|
11
12
|
messageContainer: import("antd-style").SerializedStyles;
|
|
12
13
|
name: import("antd-style").SerializedStyles;
|
|
14
|
+
time: string;
|
|
13
15
|
message: string;
|
|
14
16
|
}>;
|
package/es/ChatItem/style.js
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
|
|
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
|
|
7
|
+
token = _ref.token,
|
|
8
|
+
stylish = _ref.stylish;
|
|
8
9
|
var placement = _ref2.placement,
|
|
9
10
|
type = _ref2.type,
|
|
10
|
-
|
|
11
|
+
title = _ref2.title,
|
|
11
12
|
primary = _ref2.primary,
|
|
12
|
-
avatarSize = _ref2.avatarSize
|
|
13
|
+
avatarSize = _ref2.avatarSize,
|
|
14
|
+
showTitle = _ref2.showTitle;
|
|
13
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);
|
|
14
|
-
var pureStylish = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding-top: ", ";\n "])),
|
|
16
|
+
var pureStylish = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding-top: ", ";\n "])), title ? 0 : '6px');
|
|
15
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);
|
|
16
18
|
var typeStylish = type === 'block' ? blockStylish : pureStylish;
|
|
17
19
|
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')),
|
|
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')),
|
|
19
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),
|
|
20
22
|
avatarContainer: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n position: relative;\n flex: none;\n width: ", "px;\n height: ", "px;\n "])), avatarSize, avatarSize),
|
|
21
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 "]))),
|
|
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
|
-
|
|
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 "]))))
|
|
24
27
|
};
|
|
25
28
|
});
|
package/es/ChatList/index.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { ChatItemProps } from "../index";
|
|
3
3
|
import type { DivProps } from "../types";
|
|
4
|
+
import { ChatMessage } from "../types/chatMessage";
|
|
4
5
|
export interface ChatListProps extends DivProps {
|
|
5
6
|
/**
|
|
6
7
|
* @description Data of chat messages to be displayed
|
|
7
8
|
*/
|
|
8
9
|
data: ChatMessage[];
|
|
10
|
+
/**
|
|
11
|
+
* @description Whether to show name of the chat item
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
showTitle?: ChatItemProps['showTitle'];
|
|
9
15
|
/**
|
|
10
16
|
* @description Type of chat list
|
|
11
17
|
* @default 'chat'
|
package/es/ChatList/index.js
CHANGED
|
@@ -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", "data", "type"];
|
|
3
|
+
var _excluded = ["className", "data", "type", "showTitle"];
|
|
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 { memo } from 'react';
|
|
@@ -12,6 +12,7 @@ var ChatList = /*#__PURE__*/memo(function (_ref) {
|
|
|
12
12
|
data = _ref.data,
|
|
13
13
|
_ref$type = _ref.type,
|
|
14
14
|
type = _ref$type === void 0 ? 'chat' : _ref$type,
|
|
15
|
+
showTitle = _ref.showTitle,
|
|
15
16
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
16
17
|
var _useStyles = useStyles(),
|
|
17
18
|
cx = _useStyles.cx,
|
|
@@ -19,14 +20,17 @@ var ChatList = /*#__PURE__*/memo(function (_ref) {
|
|
|
19
20
|
return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({
|
|
20
21
|
className: cx(styles.container, className)
|
|
21
22
|
}, props), {}, {
|
|
22
|
-
children: data.map(function (item
|
|
23
|
+
children: data.map(function (item) {
|
|
23
24
|
return /*#__PURE__*/_jsx(ChatItem, {
|
|
25
|
+
avatar: item.meta,
|
|
24
26
|
borderSpacing: type === 'chat',
|
|
25
27
|
message: item.content,
|
|
26
28
|
placement: type === 'chat' ? item.role === 'user' ? 'right' : 'left' : 'left',
|
|
27
29
|
primary: item.role === 'user',
|
|
30
|
+
showTitle: showTitle,
|
|
31
|
+
time: item.updateAt || item.createAt,
|
|
28
32
|
type: type === 'chat' ? 'block' : 'pure'
|
|
29
|
-
},
|
|
33
|
+
}, item.id);
|
|
30
34
|
})
|
|
31
35
|
}));
|
|
32
36
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const useStyles: (props?: "block" | "
|
|
1
|
+
export declare const useStyles: (props?: "block" | "ghost" | "pure" | undefined) => import("antd-style").ReturnStyles<{
|
|
2
2
|
container: string;
|
|
3
3
|
button: string;
|
|
4
4
|
lang: string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const CommandIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const ControlIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare const ShiftIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare const AltIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
var strokeWidth = 2.2;
|
|
4
|
+
var iconSize = '13px';
|
|
5
|
+
export var CommandIcon = function CommandIcon() {
|
|
6
|
+
return /*#__PURE__*/_jsx("svg", {
|
|
7
|
+
fill: "none",
|
|
8
|
+
height: iconSize,
|
|
9
|
+
stroke: "currentColor",
|
|
10
|
+
strokeLinecap: "round",
|
|
11
|
+
strokeLinejoin: "round",
|
|
12
|
+
strokeWidth: strokeWidth,
|
|
13
|
+
viewBox: "0 0 24 24",
|
|
14
|
+
width: iconSize,
|
|
15
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
16
|
+
children: /*#__PURE__*/_jsx("path", {
|
|
17
|
+
d: "M18 3a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3H6a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3V6a3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3h12a3 3 0 0 0 3-3 3 3 0 0 0-3-3z"
|
|
18
|
+
})
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
export var ControlIcon = function ControlIcon() {
|
|
22
|
+
return /*#__PURE__*/_jsx("svg", {
|
|
23
|
+
className: "lucide lucide-chevron-up",
|
|
24
|
+
fill: "none",
|
|
25
|
+
height: iconSize,
|
|
26
|
+
stroke: "currentColor",
|
|
27
|
+
strokeLinecap: "round",
|
|
28
|
+
strokeLinejoin: "round",
|
|
29
|
+
strokeWidth: strokeWidth,
|
|
30
|
+
viewBox: "0 0 24 24",
|
|
31
|
+
width: iconSize,
|
|
32
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
33
|
+
children: /*#__PURE__*/_jsx("polyline", {
|
|
34
|
+
points: "18 15 12 9 6 15"
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
export var ShiftIcon = function ShiftIcon() {
|
|
39
|
+
return /*#__PURE__*/_jsx("svg", {
|
|
40
|
+
className: "lucide lucide-chevron-up",
|
|
41
|
+
fill: "none",
|
|
42
|
+
height: iconSize,
|
|
43
|
+
stroke: "currentColor",
|
|
44
|
+
strokeLinecap: "round",
|
|
45
|
+
strokeLinejoin: "round",
|
|
46
|
+
strokeWidth: strokeWidth,
|
|
47
|
+
viewBox: "0 0 24 24",
|
|
48
|
+
width: iconSize,
|
|
49
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
50
|
+
children: /*#__PURE__*/_jsx("path", {
|
|
51
|
+
d: "M9 18v-6H5l7-7 7 7h-4v6H9z"
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
export var AltIcon = function AltIcon() {
|
|
56
|
+
return /*#__PURE__*/_jsxs("svg", {
|
|
57
|
+
className: "lucide lucide-chevron-up",
|
|
58
|
+
fill: "none",
|
|
59
|
+
height: iconSize,
|
|
60
|
+
stroke: "currentColor",
|
|
61
|
+
strokeLinecap: "round",
|
|
62
|
+
strokeLinejoin: "round",
|
|
63
|
+
strokeWidth: strokeWidth,
|
|
64
|
+
viewBox: "0 0 24 24",
|
|
65
|
+
width: iconSize,
|
|
66
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
67
|
+
children: [/*#__PURE__*/_jsx("path", {
|
|
68
|
+
d: "M3 3h6l6 18h6"
|
|
69
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
70
|
+
d: "M14 3h7"
|
|
71
|
+
})]
|
|
72
|
+
});
|
|
73
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface MenuItemProps {
|
|
3
|
+
active?: boolean;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
label: ReactNode;
|
|
7
|
+
nested?: boolean;
|
|
8
|
+
selected?: boolean;
|
|
9
|
+
shortcut?: string[];
|
|
10
|
+
}
|
|
11
|
+
declare const MenuItem: import("react").ForwardRefExoticComponent<MenuItemProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
12
|
+
export default MenuItem;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["label", "icon", "disabled", "nested", "shortcut", "active", "selected"];
|
|
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 { ChevronRightIcon } from 'lucide-react';
|
|
7
|
+
import { forwardRef } from 'react';
|
|
8
|
+
import { Flexbox } from 'react-layout-kit';
|
|
9
|
+
import { AltIcon, CommandIcon, ControlIcon, ShiftIcon } from "./icons";
|
|
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 KEYBOARD_ICON_MAP = {
|
|
14
|
+
meta: /*#__PURE__*/_jsx(CommandIcon, {}),
|
|
15
|
+
control: /*#__PURE__*/_jsx(ControlIcon, {}),
|
|
16
|
+
shift: /*#__PURE__*/_jsx(ShiftIcon, {}),
|
|
17
|
+
alt: /*#__PURE__*/_jsx(AltIcon, {}),
|
|
18
|
+
enter: '↵'
|
|
19
|
+
};
|
|
20
|
+
var CODE_MAP = {
|
|
21
|
+
meta: 'meta',
|
|
22
|
+
command: 'meta',
|
|
23
|
+
cmd: 'meta',
|
|
24
|
+
ctl: 'control',
|
|
25
|
+
control: 'control',
|
|
26
|
+
shift: 'shift',
|
|
27
|
+
alt: 'alt'
|
|
28
|
+
};
|
|
29
|
+
var MenuItem = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
30
|
+
var _cx;
|
|
31
|
+
var label = _ref.label,
|
|
32
|
+
icon = _ref.icon,
|
|
33
|
+
disabled = _ref.disabled,
|
|
34
|
+
nested = _ref.nested,
|
|
35
|
+
shortcut = _ref.shortcut,
|
|
36
|
+
active = _ref.active,
|
|
37
|
+
selected = _ref.selected,
|
|
38
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
39
|
+
var _useStyles = useStyles(),
|
|
40
|
+
styles = _useStyles.styles,
|
|
41
|
+
cx = _useStyles.cx;
|
|
42
|
+
return /*#__PURE__*/_jsxs("button", _objectSpread(_objectSpread({
|
|
43
|
+
type: 'button'
|
|
44
|
+
}, props), {}, {
|
|
45
|
+
className: cx(styles.item, (_cx = {}, _defineProperty(_cx, styles.selected, selected), _defineProperty(_cx, styles.active, active), _cx)),
|
|
46
|
+
disabled: disabled,
|
|
47
|
+
ref: ref,
|
|
48
|
+
role: "menuitem",
|
|
49
|
+
children: [/*#__PURE__*/_jsxs(Flexbox, {
|
|
50
|
+
gap: 8,
|
|
51
|
+
horizontal: true,
|
|
52
|
+
children: [icon && /*#__PURE__*/_jsx("span", {
|
|
53
|
+
children: icon
|
|
54
|
+
}), label]
|
|
55
|
+
}), nested ? /*#__PURE__*/_jsx("span", {
|
|
56
|
+
"aria-hidden": true,
|
|
57
|
+
children: /*#__PURE__*/_jsx(ChevronRightIcon, {
|
|
58
|
+
className: styles.arrow
|
|
59
|
+
})
|
|
60
|
+
}) : shortcut ? /*#__PURE__*/_jsx(Flexbox, {
|
|
61
|
+
align: 'center',
|
|
62
|
+
horizontal: true,
|
|
63
|
+
children: shortcut.map(function (c) {
|
|
64
|
+
var code = CODE_MAP[c.toLowerCase()];
|
|
65
|
+
return /*#__PURE__*/_jsx("kbd", {
|
|
66
|
+
className: styles.kbd,
|
|
67
|
+
children: code ? KEYBOARD_ICON_MAP[code] : c.toUpperCase()
|
|
68
|
+
}, c);
|
|
69
|
+
})
|
|
70
|
+
}) : null]
|
|
71
|
+
}));
|
|
72
|
+
});
|
|
73
|
+
export default MenuItem;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
3
|
+
import { createStyles } from 'antd-style';
|
|
4
|
+
export var useStyles = createStyles(function (_ref, prefixCls) {
|
|
5
|
+
var css = _ref.css,
|
|
6
|
+
cx = _ref.cx,
|
|
7
|
+
token = _ref.token;
|
|
8
|
+
var selected = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n font-weight: bold;\n color: ", ";\n background: ", ";\n\n &:hover {\n color: ", ";\n background: ", ";\n }\n "])), token.colorPrimaryText, token.colorPrimaryBg, token.colorPrimaryTextHover, token.colorPrimaryBgHover);
|
|
9
|
+
return {
|
|
10
|
+
item: cx("".concat(prefixCls, "-item"), css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n all: unset;\n\n user-select: none;\n scroll-margin: 50px;\n\n display: flex;\n align-items: center;\n justify-content: space-between;\n\n box-sizing: inherit;\n width: 100%;\n padding: 12px 10px;\n\n font-family: ", ";\n font-weight: normal;\n line-height: 1;\n color: ", ";\n\n background: transparent;\n border-radius: 5px;\n\n &:hover {\n background: ", ";\n }\n "])), token.fontFamily, token.colorText, token.colorFillTertiary)),
|
|
11
|
+
selected: cx("".concat(prefixCls, "-item-selected"), selected),
|
|
12
|
+
active: cx("".concat(prefixCls, "-item-active"), css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n background: ", ";\n "])), token.colorFillTertiary)),
|
|
13
|
+
arrow: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n color: ", ";\n "])), token.colorTextTertiary),
|
|
14
|
+
kbd: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n justify-content: center;\n\n width: 18px;\n height: 20px;\n\n font-family: ", ";\n font-size: 14px;\n color: ", ";\n\n border-radius: 2px;\n "])), token.fontFamily, token.colorTextQuaternary)
|
|
15
|
+
};
|
|
16
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import MenuItem from './MenuItem';
|
|
2
|
+
import { MenuItemType } from './types';
|
|
3
|
+
export interface ContextMenuProps {
|
|
4
|
+
/**
|
|
5
|
+
* @description Container element for the context menu
|
|
6
|
+
*/
|
|
7
|
+
container?: HTMLElement;
|
|
8
|
+
/**
|
|
9
|
+
* @description Items to be displayed in the context menu
|
|
10
|
+
*/
|
|
11
|
+
items: MenuItemType[];
|
|
12
|
+
/**
|
|
13
|
+
* @description Label for the context menu
|
|
14
|
+
*/
|
|
15
|
+
label?: string;
|
|
16
|
+
}
|
|
17
|
+
export default MenuItem;
|
package/es/Menu/index.js
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["items", "label", "container"];
|
|
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 { FloatingFocusManager, FloatingNode, FloatingPortal, autoUpdate, flip, offset, safePolygon, shift, useClick, useDismiss, useFloating, useFloatingNodeId, useFloatingParentNodeId, useFloatingTree, useHover, useInteractions, useListNavigation, useMergeRefs, useRole, useTypeahead } from '@floating-ui/react';
|
|
8
|
+
import { Divider } from 'antd';
|
|
9
|
+
import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
|
|
10
|
+
import MenuItem from "./MenuItem";
|
|
11
|
+
import { useStyles } from "./style";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
var MenuComponent = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
|
|
15
|
+
var items = _ref.items,
|
|
16
|
+
label = _ref.label,
|
|
17
|
+
container = _ref.container,
|
|
18
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
19
|
+
var _useStyles = useStyles(),
|
|
20
|
+
styles = _useStyles.styles;
|
|
21
|
+
var _useState = useState(false),
|
|
22
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
23
|
+
isOpen = _useState2[0],
|
|
24
|
+
setIsOpen = _useState2[1];
|
|
25
|
+
var _useState3 = useState(null),
|
|
26
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
27
|
+
activeIndex = _useState4[0],
|
|
28
|
+
setActiveIndex = _useState4[1];
|
|
29
|
+
var _useState5 = useState(false),
|
|
30
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
31
|
+
allowHover = _useState6[0],
|
|
32
|
+
setAllowHover = _useState6[1];
|
|
33
|
+
var listItemsRef = useRef([]);
|
|
34
|
+
var listContentRef = useRef(items.map(function (item) {
|
|
35
|
+
return item.label;
|
|
36
|
+
}));
|
|
37
|
+
var allowMouseUpCloseRef = useRef(false);
|
|
38
|
+
var tree = useFloatingTree();
|
|
39
|
+
var nodeId = useFloatingNodeId();
|
|
40
|
+
var parentId = useFloatingParentNodeId();
|
|
41
|
+
var isNested = parentId !== null;
|
|
42
|
+
var _useFloating = useFloating({
|
|
43
|
+
nodeId: nodeId,
|
|
44
|
+
open: isOpen,
|
|
45
|
+
onOpenChange: setIsOpen,
|
|
46
|
+
placement: isNested ? 'right-start' : 'bottom-start',
|
|
47
|
+
middleware: [offset({
|
|
48
|
+
mainAxis: isNested ? 0 : 4,
|
|
49
|
+
alignmentAxis: isNested ? -4 : 0
|
|
50
|
+
}), flip(), shift()],
|
|
51
|
+
whileElementsMounted: autoUpdate
|
|
52
|
+
}),
|
|
53
|
+
refs = _useFloating.refs,
|
|
54
|
+
context = _useFloating.context;
|
|
55
|
+
var hover = useHover(context, {
|
|
56
|
+
enabled: isNested && allowHover,
|
|
57
|
+
delay: {
|
|
58
|
+
open: 75
|
|
59
|
+
},
|
|
60
|
+
handleClose: safePolygon({
|
|
61
|
+
blockPointerEvents: true
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
var click = useClick(context, {
|
|
65
|
+
event: 'mousedown',
|
|
66
|
+
toggle: !isNested || !allowHover,
|
|
67
|
+
ignoreMouse: isNested
|
|
68
|
+
});
|
|
69
|
+
var role = useRole(context, {
|
|
70
|
+
role: 'menu'
|
|
71
|
+
});
|
|
72
|
+
var dismiss = useDismiss(context);
|
|
73
|
+
var listNavigation = useListNavigation(context, {
|
|
74
|
+
listRef: listItemsRef,
|
|
75
|
+
activeIndex: activeIndex,
|
|
76
|
+
nested: isNested,
|
|
77
|
+
onNavigate: setActiveIndex
|
|
78
|
+
});
|
|
79
|
+
var typeahead = useTypeahead(context, {
|
|
80
|
+
enabled: isOpen,
|
|
81
|
+
listRef: listContentRef,
|
|
82
|
+
onMatch: isOpen ? setActiveIndex : undefined,
|
|
83
|
+
activeIndex: activeIndex
|
|
84
|
+
});
|
|
85
|
+
var _useInteractions = useInteractions([hover, click, role, dismiss, listNavigation, typeahead]),
|
|
86
|
+
getReferenceProps = _useInteractions.getReferenceProps,
|
|
87
|
+
getFloatingProps = _useInteractions.getFloatingProps,
|
|
88
|
+
getItemProps = _useInteractions.getItemProps;
|
|
89
|
+
|
|
90
|
+
// Event emitter allows you to communicate across tree components.
|
|
91
|
+
// This effect closes all menus when an item gets clicked anywhere
|
|
92
|
+
// in the tree.
|
|
93
|
+
useEffect(function () {
|
|
94
|
+
if (!tree) return;
|
|
95
|
+
function handleTreeClick() {
|
|
96
|
+
setIsOpen(false);
|
|
97
|
+
}
|
|
98
|
+
function onSubMenuOpen(event) {
|
|
99
|
+
if (event.nodeId !== nodeId && event.parentId === parentId) {
|
|
100
|
+
setIsOpen(false);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
tree.events.on('click', handleTreeClick);
|
|
104
|
+
tree.events.on('menuopen', onSubMenuOpen);
|
|
105
|
+
return function () {
|
|
106
|
+
tree.events.off('click', handleTreeClick);
|
|
107
|
+
tree.events.off('menuopen', onSubMenuOpen);
|
|
108
|
+
};
|
|
109
|
+
}, [tree, nodeId, parentId]);
|
|
110
|
+
useEffect(function () {
|
|
111
|
+
if (isOpen && tree) {
|
|
112
|
+
tree.events.emit('menuopen', {
|
|
113
|
+
parentId: parentId,
|
|
114
|
+
nodeId: nodeId
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}, [tree, isOpen, nodeId, parentId]);
|
|
118
|
+
|
|
119
|
+
// Determine if "hover" logic can run based on the modality of input. This
|
|
120
|
+
// prevents unwanted focus synchronization as menus open and close with
|
|
121
|
+
// keyboard navigation and the cursor is resting on the menu.
|
|
122
|
+
useEffect(function () {
|
|
123
|
+
function onPointerMove(_ref2) {
|
|
124
|
+
var pointerType = _ref2.pointerType;
|
|
125
|
+
if (pointerType !== 'touch') {
|
|
126
|
+
setAllowHover(true);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function onKeyDown() {
|
|
130
|
+
setAllowHover(false);
|
|
131
|
+
}
|
|
132
|
+
window.addEventListener('pointermove', onPointerMove, {
|
|
133
|
+
once: true,
|
|
134
|
+
capture: true
|
|
135
|
+
});
|
|
136
|
+
window.addEventListener('keydown', onKeyDown, true);
|
|
137
|
+
return function () {
|
|
138
|
+
window.removeEventListener('pointermove', onPointerMove, {
|
|
139
|
+
capture: true
|
|
140
|
+
});
|
|
141
|
+
window.removeEventListener('keydown', onKeyDown, true);
|
|
142
|
+
};
|
|
143
|
+
}, [allowHover]);
|
|
144
|
+
useEffect(function () {
|
|
145
|
+
var timeout;
|
|
146
|
+
function onContextMenu(e) {
|
|
147
|
+
e.preventDefault();
|
|
148
|
+
refs.setPositionReference({
|
|
149
|
+
getBoundingClientRect: function getBoundingClientRect() {
|
|
150
|
+
return {
|
|
151
|
+
width: 0,
|
|
152
|
+
height: 0,
|
|
153
|
+
x: e.clientX,
|
|
154
|
+
y: e.clientY,
|
|
155
|
+
top: e.clientY,
|
|
156
|
+
right: e.clientX,
|
|
157
|
+
bottom: e.clientY,
|
|
158
|
+
left: e.clientX
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
setIsOpen(true);
|
|
163
|
+
clearTimeout(timeout);
|
|
164
|
+
allowMouseUpCloseRef.current = false;
|
|
165
|
+
timeout = window.setTimeout(function () {
|
|
166
|
+
allowMouseUpCloseRef.current = true;
|
|
167
|
+
}, 300);
|
|
168
|
+
}
|
|
169
|
+
function onMouseUp() {
|
|
170
|
+
if (allowMouseUpCloseRef.current) {
|
|
171
|
+
setIsOpen(false);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
document.addEventListener('contextmenu', onContextMenu);
|
|
175
|
+
document.addEventListener('mouseup', onMouseUp);
|
|
176
|
+
return function () {
|
|
177
|
+
document.removeEventListener('contextmenu', onContextMenu);
|
|
178
|
+
document.removeEventListener('mouseup', onMouseUp);
|
|
179
|
+
clearTimeout(timeout);
|
|
180
|
+
};
|
|
181
|
+
}, [refs, container]);
|
|
182
|
+
var renderMenuItem = useCallback(function (item, index) {
|
|
183
|
+
// 支持渲染分割线
|
|
184
|
+
if ('type' in item && item.type === 'divider') return /*#__PURE__*/_jsx(Divider, {
|
|
185
|
+
style: {
|
|
186
|
+
margin: '4px 12px',
|
|
187
|
+
minWidth: 'auto',
|
|
188
|
+
width: 'auto'
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
var data = item;
|
|
192
|
+
var props = _objectSpread({
|
|
193
|
+
label: data.label,
|
|
194
|
+
key: data.key,
|
|
195
|
+
icon: data.icon,
|
|
196
|
+
shortcut: data.shortcut,
|
|
197
|
+
active: activeIndex === index
|
|
198
|
+
}, getItemProps({
|
|
199
|
+
ref: function ref(node) {
|
|
200
|
+
listItemsRef.current[index] = node;
|
|
201
|
+
},
|
|
202
|
+
onClick: function onClick() {
|
|
203
|
+
var _data$onClick;
|
|
204
|
+
(_data$onClick = data.onClick) === null || _data$onClick === void 0 ? void 0 : _data$onClick.call(data);
|
|
205
|
+
setIsOpen(false);
|
|
206
|
+
},
|
|
207
|
+
onMouseUp: function onMouseUp() {
|
|
208
|
+
var _data$onClick2;
|
|
209
|
+
(_data$onClick2 = data.onClick) === null || _data$onClick2 === void 0 ? void 0 : _data$onClick2.call(data);
|
|
210
|
+
setIsOpen(false);
|
|
211
|
+
}
|
|
212
|
+
}));
|
|
213
|
+
if ('children' in item) {
|
|
214
|
+
return /*#__PURE__*/_jsx(MenuComponent, _objectSpread(_objectSpread({}, props), {}, {
|
|
215
|
+
items: item.children
|
|
216
|
+
}));
|
|
217
|
+
}
|
|
218
|
+
return /*#__PURE__*/_jsx(MenuItem, _objectSpread({}, props));
|
|
219
|
+
}, [activeIndex]);
|
|
220
|
+
var referenceRef = useMergeRefs([refs.setReference, forwardedRef]);
|
|
221
|
+
return /*#__PURE__*/_jsxs(FloatingNode, {
|
|
222
|
+
id: nodeId,
|
|
223
|
+
children: [!label ? null : /*#__PURE__*/_jsx(MenuItem, _objectSpread(_objectSpread({
|
|
224
|
+
label: label,
|
|
225
|
+
nested: isNested,
|
|
226
|
+
ref: referenceRef,
|
|
227
|
+
role: isNested ? 'menuitem' : 'menu'
|
|
228
|
+
}, props), getReferenceProps({
|
|
229
|
+
onClick: function onClick(event) {
|
|
230
|
+
event.stopPropagation();
|
|
231
|
+
}
|
|
232
|
+
}))), /*#__PURE__*/_jsx(FloatingPortal, {
|
|
233
|
+
children: isOpen && /*#__PURE__*/_jsx(FloatingFocusManager, {
|
|
234
|
+
context: context,
|
|
235
|
+
initialFocus: isNested ? -1 : 0,
|
|
236
|
+
modal: false,
|
|
237
|
+
returnFocus: !isNested,
|
|
238
|
+
children: /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({
|
|
239
|
+
className: styles.container,
|
|
240
|
+
ref: refs.setFloating
|
|
241
|
+
}, getFloatingProps()), {}, {
|
|
242
|
+
children: items === null || items === void 0 ? void 0 : items.map(renderMenuItem)
|
|
243
|
+
}))
|
|
244
|
+
})
|
|
245
|
+
})]
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
export default MenuItem;
|
package/es/Menu/style.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2;
|
|
3
|
+
import { createStyles } from 'antd-style';
|
|
4
|
+
export var useStyles = createStyles(function (_ref, prefixCls) {
|
|
5
|
+
var css = _ref.css,
|
|
6
|
+
cx = _ref.cx,
|
|
7
|
+
token = _ref.token;
|
|
8
|
+
return {
|
|
9
|
+
container: cx(prefixCls, css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n user-select: none;\n scrollbar-width: none;\n\n overflow-y: auto;\n overscroll-behavior: contain;\n\n box-sizing: border-box;\n width: 200px;\n padding: 5px;\n\n font-size: ", ";\n\n background: ", ";\n border: 1px solid ", ";\n border-radius: 8px;\n outline: 0;\n box-shadow: ", ";\n\n &::-webkit-scrollbar {\n display: none;\n }\n "])), token.fontSize, token.colorBgContainer, token.colorBorder, token.boxShadowSecondary)),
|
|
10
|
+
button: cx("".concat(prefixCls, "-button"), css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n all: unset;\n\n cursor: default;\n user-select: none;\n\n padding: 12px 10px;\n\n font-size: ", "px;\n line-height: 1;\n color: ", ";\n\n background: ", ";\n border: 1px solid ", ";\n border-radius: ", "px;\n\n -webkit-tap-highlight-color: transparent;\n\n &:hover {\n background: ", ";\n border-color: transparent;\n }\n\n &:focus-visible {\n border-color: ", ";\n box-shadow: 0 0 0 2px ", ";\n }\n "])), token.fontSize, token.colorText, token.colorBgContainer, token.colorBorder, token.borderRadius, token.colorPrimaryBg, token.colorPrimary, token.colorPrimaryBg))
|
|
11
|
+
};
|
|
12
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface CommonType {
|
|
3
|
+
icon?: ReactNode;
|
|
4
|
+
key: string;
|
|
5
|
+
label: string;
|
|
6
|
+
onClick?: () => void;
|
|
7
|
+
}
|
|
8
|
+
export interface GeneralItemType extends CommonType {
|
|
9
|
+
danger?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
shortcut?: ('meta' | 'control' | 'shift' | 'alt' | string)[];
|
|
12
|
+
}
|
|
13
|
+
export interface SubMenuType extends CommonType {
|
|
14
|
+
children: MenuItemType[];
|
|
15
|
+
}
|
|
16
|
+
export interface MenuDividerType {
|
|
17
|
+
dashed?: boolean;
|
|
18
|
+
type: 'divider';
|
|
19
|
+
}
|
|
20
|
+
export declare type MenuItemType = GeneralItemType | SubMenuType | MenuDividerType;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/es/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as ActionIcon, type ActionIconProps, type ActionIconSize } from './ActionIcon';
|
|
2
|
+
export { default as ActionIconGroup, type ActionIconGroupProps } from './ActionIconGroup';
|
|
2
3
|
export { default as Avatar, type AvatarProps } from './Avatar';
|
|
3
4
|
export type { ChatMessage, MessageRoleType } from './Chat';
|
|
4
5
|
export { default as ChatItem, type ChatItemProps } from './ChatItem';
|
package/es/index.js
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { LLMRoleType } from './llm';
|
|
2
|
+
import { BaseDataModel } from './meta';
|
|
3
|
+
/**
|
|
4
|
+
* 聊天消息错误对象
|
|
5
|
+
*/
|
|
6
|
+
export interface ChatMessageError {
|
|
7
|
+
/**
|
|
8
|
+
* 错误信息
|
|
9
|
+
*/
|
|
10
|
+
message: string;
|
|
11
|
+
status: number;
|
|
12
|
+
type: 'general' | 'llm';
|
|
13
|
+
}
|
|
14
|
+
export interface ChatMessage extends BaseDataModel {
|
|
15
|
+
/**
|
|
16
|
+
* @title 内容
|
|
17
|
+
* @description 消息内容
|
|
18
|
+
*/
|
|
19
|
+
content: string;
|
|
20
|
+
extra?: {
|
|
21
|
+
translate: {
|
|
22
|
+
target: string;
|
|
23
|
+
to: string;
|
|
24
|
+
};
|
|
25
|
+
} & Record<string, any>;
|
|
26
|
+
parentId?: string;
|
|
27
|
+
quotaId?: string;
|
|
28
|
+
/**
|
|
29
|
+
* 角色
|
|
30
|
+
* @description 消息发送者的角色
|
|
31
|
+
*/
|
|
32
|
+
role: LLMRoleType;
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM 模型
|
|
3
|
+
*/
|
|
4
|
+
export declare enum LanguageModel {
|
|
5
|
+
/**
|
|
6
|
+
* GPT 3.5 Turbo
|
|
7
|
+
*/
|
|
8
|
+
GPT3_5 = "gpt-3.5-turbo",
|
|
9
|
+
/**
|
|
10
|
+
* GPT 4
|
|
11
|
+
*/
|
|
12
|
+
GPT4 = "gpt-4"
|
|
13
|
+
}
|
|
14
|
+
export interface LLMParams {
|
|
15
|
+
/**
|
|
16
|
+
* 控制生成文本中的惩罚系数,用于减少重复性
|
|
17
|
+
*/
|
|
18
|
+
frequency_penalty?: number;
|
|
19
|
+
/**
|
|
20
|
+
* 生成文本的最大长度
|
|
21
|
+
*/
|
|
22
|
+
max_tokens?: number;
|
|
23
|
+
/**
|
|
24
|
+
* 控制生成文本中的惩罚系数,用于减少主题的变化
|
|
25
|
+
*/
|
|
26
|
+
presence_penalty?: number;
|
|
27
|
+
/**
|
|
28
|
+
* 生成文本的随机度量,用于控制文本的创造性和多样性
|
|
29
|
+
* @default 0.8
|
|
30
|
+
*/
|
|
31
|
+
temperature: number;
|
|
32
|
+
/**
|
|
33
|
+
* 控制生成文本中最高概率的单个 token
|
|
34
|
+
*/
|
|
35
|
+
top_p?: number;
|
|
36
|
+
}
|
|
37
|
+
export declare type LLMRoleType = 'user' | 'system' | 'assistant';
|
|
38
|
+
export interface LLMMessage {
|
|
39
|
+
content: string;
|
|
40
|
+
role: LLMRoleType;
|
|
41
|
+
}
|
|
42
|
+
export declare type LLMExample = LLMMessage[];
|
package/es/types/llm.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface MetaData {
|
|
2
|
+
/**
|
|
3
|
+
* 角色头像
|
|
4
|
+
* @description 可选参数,如果不传则使用默认头像
|
|
5
|
+
*/
|
|
6
|
+
avatar?: string;
|
|
7
|
+
/**
|
|
8
|
+
* 背景色
|
|
9
|
+
* @description 可选参数,如果不传则使用默认背景色
|
|
10
|
+
*/
|
|
11
|
+
backgroundColor?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
tag?: string[];
|
|
14
|
+
/**
|
|
15
|
+
* 名称
|
|
16
|
+
* @description 可选参数,如果不传则使用默认名称
|
|
17
|
+
*/
|
|
18
|
+
title?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface BaseDataModel {
|
|
21
|
+
createAt?: number;
|
|
22
|
+
id: string;
|
|
23
|
+
meta: MetaData;
|
|
24
|
+
updateAt?: number;
|
|
25
|
+
}
|
package/es/types/meta.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const formatTime: (time: number) => string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
export var formatTime = function formatTime(time) {
|
|
3
|
+
var now = dayjs();
|
|
4
|
+
var target = dayjs(time);
|
|
5
|
+
if (target.isSame(now, 'day')) {
|
|
6
|
+
return target.format('HH:mm');
|
|
7
|
+
} else if (target.isSame(now, 'year')) {
|
|
8
|
+
return target.format('MM-DD HH:mm');
|
|
9
|
+
} else {
|
|
10
|
+
return target.format('YYYY-MM-DD HH:mm');
|
|
11
|
+
}
|
|
12
|
+
};
|