@lobehub/ui 1.68.0 → 1.70.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/ChatItem/components/Actions.d.ts +9 -0
- package/es/ChatItem/components/Actions.js +19 -0
- package/es/ChatItem/components/Avatar.d.ts +12 -0
- package/es/ChatItem/components/Avatar.js +42 -0
- package/es/ChatItem/components/BorderSpacing.d.ts +7 -0
- package/es/ChatItem/components/BorderSpacing.js +13 -0
- package/es/ChatItem/components/ErrorContent.d.ts +9 -0
- package/es/ChatItem/components/ErrorContent.js +27 -0
- package/es/ChatItem/components/Loading.d.ts +8 -0
- package/es/ChatItem/components/Loading.js +26 -0
- package/es/ChatItem/components/MessageContent.d.ts +16 -0
- package/es/ChatItem/components/MessageContent.js +45 -0
- package/es/ChatItem/components/Title.d.ts +10 -0
- package/es/ChatItem/components/Title.js +23 -0
- package/es/ChatItem/index.d.ts +3 -74
- package/es/ChatItem/index.js +44 -71
- package/es/ChatItem/style.d.ts +2 -1
- package/es/ChatItem/style.js +10 -9
- package/es/ChatItem/type.d.ts +76 -0
- package/es/ChatItem/type.js +1 -0
- package/es/ChatList/Group.d.ts +8 -0
- package/es/ChatList/Group.js +74 -0
- package/es/ChatList/Item.d.ts +9 -2
- package/es/ChatList/Item.js +20 -13
- package/es/ChatList/index.d.ts +2 -7
- package/es/ChatList/index.js +14 -5
- package/es/GridBackground/Grid.d.ts +26 -0
- package/es/GridBackground/Grid.js +99 -0
- package/es/GridBackground/GridShowcase.d.ts +8 -0
- package/es/GridBackground/GridShowcase.js +49 -0
- package/es/GridBackground/index.d.ts +16 -0
- package/es/GridBackground/index.js +87 -0
- package/es/GridBackground/style.d.ts +9 -0
- package/es/GridBackground/style.js +22 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +2 -0
- package/es/types/chatMessage.d.ts +5 -2
- package/package.json +1 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { AlertProps } from 'antd';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { EditableMessageProps } from "../EditableMessage";
|
|
4
|
+
import { MetaData } from "../types";
|
|
5
|
+
export interface ChatItemProps {
|
|
6
|
+
ErrorMessage?: ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* @description Actions to be displayed in the chat item
|
|
9
|
+
*/
|
|
10
|
+
actions?: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* @description Metadata for the avatar
|
|
13
|
+
*/
|
|
14
|
+
avatar: MetaData;
|
|
15
|
+
avatarAddon?: ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* @description Whether to add border spacing
|
|
18
|
+
*/
|
|
19
|
+
borderSpacing?: number | string;
|
|
20
|
+
/**
|
|
21
|
+
* @description Custom CSS class name for the chat item
|
|
22
|
+
*/
|
|
23
|
+
className?: string;
|
|
24
|
+
/**
|
|
25
|
+
* @description Whether the chat item is in editing mode
|
|
26
|
+
*/
|
|
27
|
+
editing?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* @description Props for Error render
|
|
30
|
+
*/
|
|
31
|
+
error?: AlertProps;
|
|
32
|
+
/**
|
|
33
|
+
* @description Whether the chat item is in loading state
|
|
34
|
+
*/
|
|
35
|
+
loading?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* @description The message content of the chat item
|
|
38
|
+
*/
|
|
39
|
+
message?: ReactNode;
|
|
40
|
+
messageExtra?: ReactNode;
|
|
41
|
+
onAvatarClick?: () => void;
|
|
42
|
+
/**
|
|
43
|
+
* @description Callback when the message content changes
|
|
44
|
+
* @param value - The new message content
|
|
45
|
+
*/
|
|
46
|
+
onChange?: (value: string) => void;
|
|
47
|
+
/**
|
|
48
|
+
* @description Callback when the editing mode changes
|
|
49
|
+
* @param editing - The new editing mode
|
|
50
|
+
*/
|
|
51
|
+
onEditingChange?: (editing: boolean) => void;
|
|
52
|
+
/**
|
|
53
|
+
* @description The placement of the chat item
|
|
54
|
+
* @default 'left'
|
|
55
|
+
*/
|
|
56
|
+
placement?: 'left' | 'right';
|
|
57
|
+
/**
|
|
58
|
+
* @description Whether the chat item is primary
|
|
59
|
+
*/
|
|
60
|
+
primary?: boolean;
|
|
61
|
+
renderMessage?: (content: ReactNode) => ReactNode;
|
|
62
|
+
/**
|
|
63
|
+
* @description Whether to show the title of the chat item
|
|
64
|
+
*/
|
|
65
|
+
showTitle?: boolean;
|
|
66
|
+
text?: EditableMessageProps['text'];
|
|
67
|
+
/**
|
|
68
|
+
* @description The timestamp of the chat item
|
|
69
|
+
*/
|
|
70
|
+
time?: number;
|
|
71
|
+
/**
|
|
72
|
+
* @description The type of the chat item
|
|
73
|
+
* @default 'block'
|
|
74
|
+
*/
|
|
75
|
+
type?: 'block' | 'pure';
|
|
76
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ChatListItemProps } from './Item';
|
|
3
|
+
interface ChatListGroup {
|
|
4
|
+
data: ChatListItemProps[];
|
|
5
|
+
meta: ChatListItemProps['meta'];
|
|
6
|
+
}
|
|
7
|
+
declare const Group: import("react").NamedExoticComponent<ChatListGroup>;
|
|
8
|
+
export default Group;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
import { useTheme } from 'antd-style';
|
|
6
|
+
import { memo, useCallback, useMemo, useState } from 'react';
|
|
7
|
+
import { Flexbox } from 'react-layout-kit';
|
|
8
|
+
import Avatar from "../Avatar";
|
|
9
|
+
import Item from "./Item";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
var Group = /*#__PURE__*/memo(function (_ref) {
|
|
12
|
+
var data = _ref.data,
|
|
13
|
+
meta = _ref.meta;
|
|
14
|
+
var _useState = useState(data[0].id),
|
|
15
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
16
|
+
active = _useState2[0],
|
|
17
|
+
setActive = _useState2[1];
|
|
18
|
+
var theme = useTheme();
|
|
19
|
+
var chatItem = useMemo(function () {
|
|
20
|
+
return data.find(function (item) {
|
|
21
|
+
return item.id === active;
|
|
22
|
+
}) || data[0];
|
|
23
|
+
}, [data, active]);
|
|
24
|
+
var Nav = useCallback(function () {
|
|
25
|
+
var count = 1;
|
|
26
|
+
return data.map(function (item) {
|
|
27
|
+
var _item$meta;
|
|
28
|
+
var avatar;
|
|
29
|
+
var isAvtive = active === item.id;
|
|
30
|
+
var metaAvatar = item === null || item === void 0 ? void 0 : (_item$meta = item.meta) === null || _item$meta === void 0 ? void 0 : _item$meta.avatar;
|
|
31
|
+
switch (item.role) {
|
|
32
|
+
case 'assistant':
|
|
33
|
+
{
|
|
34
|
+
avatar = String(count);
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
case 'function':
|
|
38
|
+
{
|
|
39
|
+
avatar = metaAvatar || '🧩';
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
case 'system':
|
|
43
|
+
{
|
|
44
|
+
avatar = metaAvatar || '🚨';
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
default:
|
|
48
|
+
{
|
|
49
|
+
avatar = metaAvatar || String(count);
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
count++;
|
|
54
|
+
return /*#__PURE__*/_jsx(Avatar, {
|
|
55
|
+
avatar: avatar,
|
|
56
|
+
background: isAvtive ? theme.colorPrimary : theme.colorBgElevated,
|
|
57
|
+
onClick: function onClick() {
|
|
58
|
+
return setActive(item.id);
|
|
59
|
+
},
|
|
60
|
+
size: 20
|
|
61
|
+
}, item.id);
|
|
62
|
+
});
|
|
63
|
+
}, [active, data]);
|
|
64
|
+
return /*#__PURE__*/_jsx(Item, _objectSpread(_objectSpread({
|
|
65
|
+
groupNav: /*#__PURE__*/_jsx(Flexbox, {
|
|
66
|
+
align: 'center',
|
|
67
|
+
gap: 4,
|
|
68
|
+
children: /*#__PURE__*/_jsx(Nav, {})
|
|
69
|
+
})
|
|
70
|
+
}, chatItem), {}, {
|
|
71
|
+
meta: meta
|
|
72
|
+
}));
|
|
73
|
+
});
|
|
74
|
+
export default Group;
|
package/es/ChatList/Item.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { type ChatItemProps } from "../ChatItem";
|
|
3
|
-
import { ChatMessage, ChatMessageError } from "../types/chatMessage";
|
|
3
|
+
import { ChatMessage, ChatMessageError, MessageRoleType } from "../types/chatMessage";
|
|
4
4
|
import { type ActionsBarProps } from './ActionsBar';
|
|
5
5
|
export type OnMessageChange = (id: string, content: string) => void;
|
|
6
6
|
export type MessageExtra = (props: ChatMessage) => ReactNode;
|
|
@@ -8,6 +8,7 @@ export type OnActionClick = (actionKey: string, messageId: string) => void;
|
|
|
8
8
|
export type RenderMessage = (content: ReactNode, message: ChatMessage) => ReactNode;
|
|
9
9
|
export type RenderErrorMessage = (error: ChatMessageError, message: ChatMessage) => ReactNode;
|
|
10
10
|
export interface ListItemProps {
|
|
11
|
+
groupNav?: ChatItemProps['avatarAddon'];
|
|
11
12
|
loading?: boolean;
|
|
12
13
|
/**
|
|
13
14
|
* @description 点击操作按钮的回调函数
|
|
@@ -21,6 +22,11 @@ export interface ListItemProps {
|
|
|
21
22
|
* @description 渲染错误消息的函数
|
|
22
23
|
*/
|
|
23
24
|
renderErrorMessage?: RenderErrorMessage;
|
|
25
|
+
renderItem?: {
|
|
26
|
+
[role: MessageRoleType | string]: (data: {
|
|
27
|
+
key: string;
|
|
28
|
+
} & ChatMessage & ListItemProps) => ReactNode;
|
|
29
|
+
};
|
|
24
30
|
/**
|
|
25
31
|
* @description 渲染消息的函数
|
|
26
32
|
*/
|
|
@@ -46,5 +52,6 @@ export interface ListItemProps {
|
|
|
46
52
|
*/
|
|
47
53
|
type?: 'docs' | 'chat';
|
|
48
54
|
}
|
|
49
|
-
|
|
55
|
+
export type ChatListItemProps = ChatMessage & ListItemProps;
|
|
56
|
+
declare const Item: import("react").NamedExoticComponent<ChatListItemProps>;
|
|
50
57
|
export default Item;
|
package/es/ChatList/Item.js
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["renderMessageExtra", "showTitle", "onActionClick", "onMessageChange", "type", "text", "renderMessage", "renderErrorMessage", "loading"];
|
|
4
|
+
var _excluded = ["renderMessageExtra", "showTitle", "onActionClick", "onMessageChange", "type", "text", "renderMessage", "renderErrorMessage", "loading", "groupNav", "renderItem"];
|
|
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
8
|
import copy from 'copy-to-clipboard';
|
|
9
|
-
import { memo, useCallback, useState } from 'react';
|
|
9
|
+
import { memo, useCallback, useMemo, useState } from 'react';
|
|
10
10
|
import ChatItem from "../ChatItem";
|
|
11
11
|
import ActionsBar from "./ActionsBar";
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
var Item = /*#__PURE__*/memo(function (
|
|
13
|
+
var Item = /*#__PURE__*/memo(function (props) {
|
|
14
14
|
var _item$error;
|
|
15
|
-
var MessageExtra =
|
|
16
|
-
showTitle =
|
|
17
|
-
_onActionClick =
|
|
18
|
-
onMessageChange =
|
|
19
|
-
type =
|
|
20
|
-
text =
|
|
21
|
-
renderMessage =
|
|
22
|
-
renderErrorMessage =
|
|
23
|
-
loading =
|
|
24
|
-
|
|
15
|
+
var MessageExtra = props.renderMessageExtra,
|
|
16
|
+
showTitle = props.showTitle,
|
|
17
|
+
_onActionClick = props.onActionClick,
|
|
18
|
+
onMessageChange = props.onMessageChange,
|
|
19
|
+
type = props.type,
|
|
20
|
+
text = props.text,
|
|
21
|
+
renderMessage = props.renderMessage,
|
|
22
|
+
renderErrorMessage = props.renderErrorMessage,
|
|
23
|
+
loading = props.loading,
|
|
24
|
+
groupNav = props.groupNav,
|
|
25
|
+
renderItem = props.renderItem,
|
|
26
|
+
item = _objectWithoutProperties(props, _excluded);
|
|
25
27
|
var renderMessageExtra = MessageExtra ? /*#__PURE__*/_jsx(MessageExtra, _objectSpread({}, item)) : undefined;
|
|
26
28
|
var _useState = useState(false),
|
|
27
29
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -32,6 +34,10 @@ var Item = /*#__PURE__*/memo(function (_ref) {
|
|
|
32
34
|
var innerRenderMessage = useCallback(function (content) {
|
|
33
35
|
return renderMessage === null || renderMessage === void 0 ? void 0 : renderMessage(content, item);
|
|
34
36
|
}, [renderMessage, item]);
|
|
37
|
+
var RenderItem = useMemo(function () {
|
|
38
|
+
return renderItem && renderItem[item.role] ? renderItem[item.role] : undefined;
|
|
39
|
+
}, [renderItem]);
|
|
40
|
+
if (RenderItem) return /*#__PURE__*/_jsx(RenderItem, _objectSpread({}, props), item.id);
|
|
35
41
|
return /*#__PURE__*/_jsx(ChatItem, {
|
|
36
42
|
ErrorMessage: item.error ? renderErrorMessage === null || renderErrorMessage === void 0 ? void 0 : renderErrorMessage(item.error, item) : undefined,
|
|
37
43
|
actions: /*#__PURE__*/_jsx(ActionsBar, {
|
|
@@ -55,6 +61,7 @@ var Item = /*#__PURE__*/memo(function (_ref) {
|
|
|
55
61
|
text: text
|
|
56
62
|
}),
|
|
57
63
|
avatar: item.meta,
|
|
64
|
+
avatarAddon: groupNav,
|
|
58
65
|
editing: editing,
|
|
59
66
|
error: item.error ? {
|
|
60
67
|
message: (_item$error = item.error) === null || _item$error === void 0 ? void 0 : _item$error.message
|
package/es/ChatList/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import type { ChatMessage, DivProps
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ChatMessage, DivProps } from "../types";
|
|
3
3
|
import { ListItemProps } from './Item';
|
|
4
4
|
export interface ChatListProps extends DivProps, ListItemProps {
|
|
5
5
|
/**
|
|
@@ -7,11 +7,6 @@ export interface ChatListProps extends DivProps, ListItemProps {
|
|
|
7
7
|
*/
|
|
8
8
|
data: ChatMessage[];
|
|
9
9
|
loadingId?: string;
|
|
10
|
-
renderItem?: {
|
|
11
|
-
[role: MessageRoleType | string]: (data: {
|
|
12
|
-
key: string;
|
|
13
|
-
} & ChatMessage & ListItemProps) => ReactNode;
|
|
14
|
-
};
|
|
15
10
|
}
|
|
16
11
|
export type { OnActionClick, OnMessageChange, RenderErrorMessage, RenderMessage } from './Item';
|
|
17
12
|
declare const ChatList: import("react").NamedExoticComponent<ChatListProps>;
|
package/es/ChatList/index.js
CHANGED
|
@@ -4,6 +4,7 @@ var _excluded = ["onActionClick", "renderMessageExtra", "className", "data", "ty
|
|
|
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';
|
|
7
|
+
import Group from "./Group";
|
|
7
8
|
import Item from "./Item";
|
|
8
9
|
import { useStyles } from "./style";
|
|
9
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -29,20 +30,28 @@ var ChatList = /*#__PURE__*/memo(function (_ref) {
|
|
|
29
30
|
className: cx(styles.container, className)
|
|
30
31
|
}, props), {}, {
|
|
31
32
|
children: data.map(function (item) {
|
|
32
|
-
var
|
|
33
|
-
var props =
|
|
33
|
+
var _item$children;
|
|
34
|
+
var props = {
|
|
34
35
|
loading: loadingId === item.id,
|
|
35
36
|
onActionClick: onActionClick,
|
|
36
37
|
onMessageChange: onMessageChange,
|
|
37
38
|
renderErrorMessage: renderErrorMessage,
|
|
39
|
+
renderItem: renderItem,
|
|
38
40
|
renderMessage: renderMessage,
|
|
39
41
|
renderMessageExtra: MessageExtra,
|
|
40
42
|
showTitle: showTitle,
|
|
41
43
|
text: text,
|
|
42
44
|
type: type
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
};
|
|
46
|
+
if (item.children && ((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) > 0) {
|
|
47
|
+
return /*#__PURE__*/_jsx(Group, {
|
|
48
|
+
data: item.children.map(function (childrenItem) {
|
|
49
|
+
return _objectSpread(_objectSpread({}, props), childrenItem);
|
|
50
|
+
}),
|
|
51
|
+
meta: item.meta
|
|
52
|
+
}, item.children[0].id);
|
|
53
|
+
}
|
|
54
|
+
return /*#__PURE__*/_jsx(Item, _objectSpread(_objectSpread({}, props), item), item.id);
|
|
46
55
|
})
|
|
47
56
|
}));
|
|
48
57
|
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DivProps } from "../types";
|
|
3
|
+
declare enum Line {
|
|
4
|
+
l7 = 0,
|
|
5
|
+
l6 = 1,
|
|
6
|
+
l5 = 2,
|
|
7
|
+
l4 = 3,
|
|
8
|
+
l3 = 4,
|
|
9
|
+
l2 = 5,
|
|
10
|
+
l1 = 6,
|
|
11
|
+
center = 7,
|
|
12
|
+
r1 = 8,
|
|
13
|
+
r2 = 9,
|
|
14
|
+
r3 = 10,
|
|
15
|
+
r4 = 11,
|
|
16
|
+
r5 = 12,
|
|
17
|
+
r6 = 13,
|
|
18
|
+
r7 = 14
|
|
19
|
+
}
|
|
20
|
+
export interface GridProps extends DivProps {
|
|
21
|
+
color?: string;
|
|
22
|
+
linePick?: Line;
|
|
23
|
+
strokeWidth?: number;
|
|
24
|
+
}
|
|
25
|
+
declare const Grid: import("react").NamedExoticComponent<GridProps>;
|
|
26
|
+
export default Grid;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["color", "strokeWidth", "linePick"];
|
|
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 { isUndefined } from 'lodash-es';
|
|
7
|
+
import { memo, useCallback } from 'react';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
var Line = /*#__PURE__*/function (Line) {
|
|
12
|
+
Line[Line["l7"] = 0] = "l7";
|
|
13
|
+
Line[Line["l6"] = 1] = "l6";
|
|
14
|
+
Line[Line["l5"] = 2] = "l5";
|
|
15
|
+
Line[Line["l4"] = 3] = "l4";
|
|
16
|
+
Line[Line["l3"] = 4] = "l3";
|
|
17
|
+
Line[Line["l2"] = 5] = "l2";
|
|
18
|
+
Line[Line["l1"] = 6] = "l1";
|
|
19
|
+
Line[Line["center"] = 7] = "center";
|
|
20
|
+
Line[Line["r1"] = 8] = "r1";
|
|
21
|
+
Line[Line["r2"] = 9] = "r2";
|
|
22
|
+
Line[Line["r3"] = 10] = "r3";
|
|
23
|
+
Line[Line["r4"] = 11] = "r4";
|
|
24
|
+
Line[Line["r5"] = 12] = "r5";
|
|
25
|
+
Line[Line["r6"] = 13] = "r6";
|
|
26
|
+
Line[Line["r7"] = 14] = "r7";
|
|
27
|
+
return Line;
|
|
28
|
+
}(Line || {});
|
|
29
|
+
var Grid = /*#__PURE__*/memo(function (_ref) {
|
|
30
|
+
var _ref$color = _ref.color,
|
|
31
|
+
color = _ref$color === void 0 ? '#fff' : _ref$color,
|
|
32
|
+
_ref$strokeWidth = _ref.strokeWidth,
|
|
33
|
+
strokeWidth = _ref$strokeWidth === void 0 ? 3 : _ref$strokeWidth,
|
|
34
|
+
linePick = _ref.linePick,
|
|
35
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
36
|
+
var isUnpick = isUndefined(linePick);
|
|
37
|
+
var showLine = useCallback(function (l) {
|
|
38
|
+
return isUnpick || linePick === l;
|
|
39
|
+
}, [linePick]);
|
|
40
|
+
var vLine = /*#__PURE__*/_jsxs(_Fragment, {
|
|
41
|
+
children: [showLine(Line.l7) && /*#__PURE__*/_jsx("path", {
|
|
42
|
+
d: "M2 420v-60.343c0-21.82 14.15-41.12 34.959-47.684L1026 0h0"
|
|
43
|
+
}), showLine(Line.l6) && /*#__PURE__*/_jsx("path", {
|
|
44
|
+
d: "M268 420v-62.077c0-20.977 13.094-39.724 32.789-46.944L1149 0h0"
|
|
45
|
+
}), showLine(Line.l5) && /*#__PURE__*/_jsx("path", {
|
|
46
|
+
d: "M534 420v-64.358a50 50 0 0129.884-45.775L1269 0h0"
|
|
47
|
+
}), showLine(Line.l4) && /*#__PURE__*/_jsx("path", {
|
|
48
|
+
d: "M800 420v-67.395a50 50 0 0125.958-43.84L1389 0h0"
|
|
49
|
+
}), showLine(Line.l3) && /*#__PURE__*/_jsx("path", {
|
|
50
|
+
d: "M1066 420v-71.645a50 50 0 0120.456-40.337L1507 0h0"
|
|
51
|
+
}), showLine(Line.l2) && /*#__PURE__*/_jsx("path", {
|
|
52
|
+
d: "M1332 420v-77.506a50 50 0 0113.194-33.843L1629 0h0"
|
|
53
|
+
}), showLine(Line.l1) && /*#__PURE__*/_jsx("path", {
|
|
54
|
+
d: "M1598 420v-86.225a50 50 0 014.438-20.594L1744 0h0"
|
|
55
|
+
}), showLine(Line.center) && /*#__PURE__*/_jsx("path", {
|
|
56
|
+
d: "M1864 420V0h0"
|
|
57
|
+
}), showLine(Line.r1) && /*#__PURE__*/_jsx("path", {
|
|
58
|
+
d: "M2130 420v-86.225a50 50 0 00-4.438-20.594L1984 0h0"
|
|
59
|
+
}), showLine(Line.r2) && /*#__PURE__*/_jsx("path", {
|
|
60
|
+
d: "M2396 420v-77.506a50 50 0 00-13.194-33.843L2099 0h0"
|
|
61
|
+
}), showLine(Line.r3) && /*#__PURE__*/_jsx("path", {
|
|
62
|
+
d: "M2662 420v-71.645a50 50 0 00-20.456-40.337L2221 0h0"
|
|
63
|
+
}), showLine(Line.r4) && /*#__PURE__*/_jsx("path", {
|
|
64
|
+
d: "M2928 420v-67.395a50 50 0 00-25.958-43.84L2339 0h0"
|
|
65
|
+
}), showLine(Line.r5) && /*#__PURE__*/_jsx("path", {
|
|
66
|
+
d: "M3194 420v-64.358a50 50 0 00-29.884-45.775L2459 0h0"
|
|
67
|
+
}), showLine(Line.r6) && /*#__PURE__*/_jsx("path", {
|
|
68
|
+
d: "M3460 420v-62.077c0-20.977-13.094-39.724-32.789-46.944L2579 0h0"
|
|
69
|
+
}), showLine(Line.r7) && /*#__PURE__*/_jsx("path", {
|
|
70
|
+
d: "M3726 420v-60.343c0-21.82-14.15-41.12-34.959-47.684L2702 0h0"
|
|
71
|
+
})]
|
|
72
|
+
});
|
|
73
|
+
var hLine = isUnpick && /*#__PURE__*/_jsxs(_Fragment, {
|
|
74
|
+
children: [/*#__PURE__*/_jsx("path", {
|
|
75
|
+
d: "M2835 42H892"
|
|
76
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
77
|
+
d: "M595 136h2538"
|
|
78
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
79
|
+
d: "M237 249h3254"
|
|
80
|
+
})]
|
|
81
|
+
});
|
|
82
|
+
return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({}, props), {}, {
|
|
83
|
+
children: /*#__PURE__*/_jsx("svg", {
|
|
84
|
+
style: {
|
|
85
|
+
width: '100%'
|
|
86
|
+
},
|
|
87
|
+
viewBox: "0 0 3728 422",
|
|
88
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
89
|
+
children: /*#__PURE__*/_jsxs("g", {
|
|
90
|
+
fill: "none",
|
|
91
|
+
fillRule: "evenodd",
|
|
92
|
+
stroke: color,
|
|
93
|
+
strokeWidth: strokeWidth,
|
|
94
|
+
children: [vLine, hLine]
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
}));
|
|
98
|
+
});
|
|
99
|
+
export default Grid;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DivProps } from "../types";
|
|
3
|
+
import { type GridBackgroundProps } from './index';
|
|
4
|
+
export interface GridShowcaseProps extends DivProps {
|
|
5
|
+
backgroundColor?: GridBackgroundProps['backgroundColor'];
|
|
6
|
+
}
|
|
7
|
+
declare const GridShowcase: import("react").NamedExoticComponent<GridShowcaseProps>;
|
|
8
|
+
export default GridShowcase;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["style", "children", "backgroundColor"];
|
|
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 { useTheme } from 'antd-style';
|
|
7
|
+
import { rgba } from 'polished';
|
|
8
|
+
import { memo } from 'react';
|
|
9
|
+
import { Flexbox } from 'react-layout-kit';
|
|
10
|
+
import GridBackground from "./index";
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
var GridShowcase = /*#__PURE__*/memo(function (_ref) {
|
|
14
|
+
var style = _ref.style,
|
|
15
|
+
children = _ref.children,
|
|
16
|
+
_ref$backgroundColor = _ref.backgroundColor,
|
|
17
|
+
backgroundColor = _ref$backgroundColor === void 0 ? '#001dff' : _ref$backgroundColor,
|
|
18
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
19
|
+
var theme = useTheme();
|
|
20
|
+
return /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({
|
|
21
|
+
style: _objectSpread({
|
|
22
|
+
position: 'relative'
|
|
23
|
+
}, style)
|
|
24
|
+
}, props), {}, {
|
|
25
|
+
children: [/*#__PURE__*/_jsx(GridBackground, {
|
|
26
|
+
animation: true,
|
|
27
|
+
colorBack: rgba(theme.colorText, 0.12),
|
|
28
|
+
colorFront: rgba(theme.colorText, 0.6),
|
|
29
|
+
flip: true
|
|
30
|
+
}), /*#__PURE__*/_jsx(Flexbox, {
|
|
31
|
+
align: 'center',
|
|
32
|
+
style: {
|
|
33
|
+
zIndex: 4
|
|
34
|
+
},
|
|
35
|
+
children: children
|
|
36
|
+
}), /*#__PURE__*/_jsx(GridBackground, {
|
|
37
|
+
animation: true,
|
|
38
|
+
backgroundColor: backgroundColor,
|
|
39
|
+
colorBack: rgba(theme.colorText, 0.24),
|
|
40
|
+
colorFront: theme.colorText,
|
|
41
|
+
random: true,
|
|
42
|
+
showBackground: true,
|
|
43
|
+
style: {
|
|
44
|
+
zIndex: 0
|
|
45
|
+
}
|
|
46
|
+
})]
|
|
47
|
+
}));
|
|
48
|
+
});
|
|
49
|
+
export default GridShowcase;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DivProps } from "../types";
|
|
3
|
+
export interface GridBackgroundProps extends DivProps {
|
|
4
|
+
animation?: boolean;
|
|
5
|
+
animationDuration?: number;
|
|
6
|
+
backgroundColor?: string;
|
|
7
|
+
colorBack?: string;
|
|
8
|
+
colorFront?: string;
|
|
9
|
+
flip?: boolean;
|
|
10
|
+
random?: boolean;
|
|
11
|
+
reverse?: boolean;
|
|
12
|
+
showBackground?: boolean;
|
|
13
|
+
strokeWidth?: number;
|
|
14
|
+
}
|
|
15
|
+
declare const GridBackground: import("react").NamedExoticComponent<GridBackgroundProps>;
|
|
16
|
+
export default GridBackground;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["flip", "reverse", "showBackground", "backgroundColor", "random", "animationDuration", "className", "colorFront", "colorBack", "strokeWidth", "style", "animation"];
|
|
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 { useSize } from 'ahooks';
|
|
7
|
+
import { shuffle } from 'lodash-es';
|
|
8
|
+
import { memo, useCallback, useMemo, useRef } from 'react';
|
|
9
|
+
import Grid from "./Grid";
|
|
10
|
+
import { useStyles } from "./style";
|
|
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";
|
|
14
|
+
var GridBackground = /*#__PURE__*/memo(function (_ref) {
|
|
15
|
+
var flip = _ref.flip,
|
|
16
|
+
reverse = _ref.reverse,
|
|
17
|
+
showBackground = _ref.showBackground,
|
|
18
|
+
backgroundColor = _ref.backgroundColor,
|
|
19
|
+
random = _ref.random,
|
|
20
|
+
_ref$animationDuratio = _ref.animationDuration,
|
|
21
|
+
animationDuration = _ref$animationDuratio === void 0 ? 8 : _ref$animationDuratio,
|
|
22
|
+
className = _ref.className,
|
|
23
|
+
colorFront = _ref.colorFront,
|
|
24
|
+
colorBack = _ref.colorBack,
|
|
25
|
+
strokeWidth = _ref.strokeWidth,
|
|
26
|
+
style = _ref.style,
|
|
27
|
+
animation = _ref.animation,
|
|
28
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
29
|
+
var ref = useRef(null);
|
|
30
|
+
var size = useSize(ref);
|
|
31
|
+
var _useStyles = useStyles({
|
|
32
|
+
backgroundColor: backgroundColor,
|
|
33
|
+
reverse: reverse
|
|
34
|
+
}),
|
|
35
|
+
styles = _useStyles.styles,
|
|
36
|
+
cx = _useStyles.cx;
|
|
37
|
+
var gridProps = useMemo(function () {
|
|
38
|
+
return {
|
|
39
|
+
className: styles.highlight,
|
|
40
|
+
color: colorFront,
|
|
41
|
+
strokeWidth: strokeWidth
|
|
42
|
+
};
|
|
43
|
+
}, [reverse, colorFront, strokeWidth]);
|
|
44
|
+
var HighlightGrid = useCallback(function () {
|
|
45
|
+
if (!random) return /*#__PURE__*/_jsx(Grid, _objectSpread({
|
|
46
|
+
style: {
|
|
47
|
+
'--duration': "".concat(animationDuration, "s")
|
|
48
|
+
}
|
|
49
|
+
}, gridProps));
|
|
50
|
+
var group = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14];
|
|
51
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
52
|
+
children: shuffle(group).map(function (item, index) {
|
|
53
|
+
return /*#__PURE__*/_jsx(Grid, _objectSpread({
|
|
54
|
+
linePick: item,
|
|
55
|
+
style: {
|
|
56
|
+
'--delay': "".concat(index + Math.random(), "s"),
|
|
57
|
+
'--duration': "".concat(animationDuration, "s")
|
|
58
|
+
}
|
|
59
|
+
}, gridProps), item);
|
|
60
|
+
})
|
|
61
|
+
});
|
|
62
|
+
}, [random, animationDuration, gridProps]);
|
|
63
|
+
return /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({
|
|
64
|
+
className: cx(styles.container, className),
|
|
65
|
+
ref: ref,
|
|
66
|
+
style: flip ? _objectSpread({
|
|
67
|
+
transform: 'scaleY(-1)'
|
|
68
|
+
}, style) : style
|
|
69
|
+
}, props), {}, {
|
|
70
|
+
children: [/*#__PURE__*/_jsx(Grid, {
|
|
71
|
+
color: colorBack,
|
|
72
|
+
strokeWidth: strokeWidth,
|
|
73
|
+
style: {
|
|
74
|
+
zIndex: 2
|
|
75
|
+
}
|
|
76
|
+
}), animation && /*#__PURE__*/_jsx(HighlightGrid, {}), showBackground && /*#__PURE__*/_jsx("div", {
|
|
77
|
+
className: styles.backgroundContainer,
|
|
78
|
+
style: size ? {
|
|
79
|
+
fontSize: size.width / 80
|
|
80
|
+
} : {},
|
|
81
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
82
|
+
className: styles.background
|
|
83
|
+
})
|
|
84
|
+
})]
|
|
85
|
+
}));
|
|
86
|
+
});
|
|
87
|
+
export default GridBackground;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const useStyles: (props?: {
|
|
2
|
+
backgroundColor?: string | undefined;
|
|
3
|
+
reverse?: boolean | undefined;
|
|
4
|
+
} | undefined) => import("antd-style").ReturnStyles<{
|
|
5
|
+
background: import("antd-style").SerializedStyles;
|
|
6
|
+
backgroundContainer: import("antd-style").SerializedStyles;
|
|
7
|
+
container: import("antd-style").SerializedStyles;
|
|
8
|
+
highlight: import("antd-style").SerializedStyles;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
3
|
+
import { createStyles, keyframes } from 'antd-style';
|
|
4
|
+
import chroma from 'chroma-js';
|
|
5
|
+
export var useStyles = createStyles(function (_ref, _ref2) {
|
|
6
|
+
var css = _ref.css,
|
|
7
|
+
token = _ref.token;
|
|
8
|
+
var reverse = _ref2.reverse,
|
|
9
|
+
_ref2$backgroundColor = _ref2.backgroundColor,
|
|
10
|
+
backgroundColor = _ref2$backgroundColor === void 0 ? 'blue' : _ref2$backgroundColor;
|
|
11
|
+
var highlightAnimation = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% {\n mask-position: 100% 0%;\n }\n 16%,100% {\n mask-position: 100% 200%;\n }\n "])));
|
|
12
|
+
var highlightAnimationReverse = keyframes(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n 0% {\n mask-position: 100% 200%;\n }\n 16%,100% {\n mask-position: 100% 0%;\n }\n "])));
|
|
13
|
+
var scale = chroma.bezier([token.colorText, backgroundColor, token.colorBgLayout]).scale().mode('lch').correctLightness().colors(6);
|
|
14
|
+
var width = 24;
|
|
15
|
+
var height = 36;
|
|
16
|
+
return {
|
|
17
|
+
background: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: absolute;\n top: ", "%;\n left: ", "%;\n transform: rotateX(60deg);\n\n width: ", "%;\n height: ", "%;\n\n background: ", ";\n filter: blur(2em) saturate(400%);\n border-radius: 50%;\n box-shadow:\n 0 0 1em 2em ", ",\n 0 0 3em 6em ", ",\n 0 0 6em 10em ", ",\n 0 0 8em 16em ", ";\n "])), 60 - height / 2, 50 - width / 2, width, height, scale[1], scale[1], scale[2], scale[3], scale[4]),
|
|
18
|
+
backgroundContainer: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: absolute;\n z-index: -1;\n inset: 0;\n\n width: 100%;\n height: 100%;\n\n perspective: 200px;\n "]))),
|
|
19
|
+
container: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n position: relative;\n\n mask-image: linear-gradient(to bottom, transparent, #fff 30%, #fff 70%, transparent);\n mask-size: cover;\n "]))),
|
|
20
|
+
highlight: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n --duration: 6s;\n --delay: 0s;\n\n position: absolute;\n z-index: 1;\n inset: 0;\n\n animation: ", " var(--duration)\n cubic-bezier(0.62, 0.62, 0.28, 0.67) infinite;\n animation-delay: var(--delay);\n\n mask-image: linear-gradient(to bottom, transparent 40%, #fff 60%, transparent);\n mask-size: 100% 200%;\n "])), reverse ? highlightAnimationReverse : highlightAnimation)
|
|
21
|
+
};
|
|
22
|
+
});
|